Hide Add to Cart button on Product description page of a particular
-
I want to hide Add to Cart button on woocommerce Product description page of a particular product with product id, say, 1234.
Following code hides Add to Cart button on woocommerce Product description pages of ALL the products:
function remove_product_description_add_cart_button(){ remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); } add_action('init','remove_product_description_add_cart_button');
But when I try to apply the above remove_action for the particular product having product id 1234 using following code, it does not work?
function remove_product_description_add_cart_button(){ global $product; //Remove Add to Cart button from product description of product with id 1234 if ($product->id == 1234){ remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); } } add_action('init','remove_product_description_add_cart_button');
What is wrong with the later and how could it be corrected?
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hide Add to Cart button on Product description page of a particular’ is closed to new replies.