I'm new to writing WordPress plugins. I'm trying to write a little plugin that modifies how the woocommerce plugin displays images on the single product page. Specifically, if there is no product image, make the div holding the image "display:none" rather than displaying a placeholder image there. The strategy I'm using is to use add_action to render my own version of woocommerce's product_image.php template and then (trying to) use remove_action to prevent the original product_image.php file from being rendered. The add_action is clearly working, as I can see the "display:none" div in Firebug. However, the remove_action isn't succeeding.
Here is my code:
$add_result = add_action( 'woocommerce_before_single_product_summary', 'eba_wc_show_product_images', 10);
function eba_wc_show_product_images() {
include( 'eba_product-image.php' );
}
$remove_result = remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 30);
echo "<hr/>result of add_result = " . $add_result . "<hr/>";
echo "<hr/>result of remove_result = " . $remove_result . "<hr/>";
The priority on the original add_action for the woocommerce_before_single_product_summary hook was 20, so I made the priority on the remove_action 30.
The two debugging statements at the end show that the add_action is returning "1", but the result of the remove_action is empty. Any help would be greatly appreciated.