I'm trying to hide the 'add to cart' button for some products (based on the type of product and custom variable is_customized).

If the custom variable is_customized is true only then show the 'add to cart' button.

I cannot find a hook using which I can remove/hide the button and then add it again if the is_customized is true.


I don't know whether my solution is perfect. But it works. Normally if is_purchasable is returned to the filter woocommerce_is_purchasable, the ‘Add to Cart’ button is displayed, and if false is returned the button is hidden. So, you just need to add the following:

add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2);

function my_woocommerce_is_purchasable($is_purchasable, $product) {
 // Write code to access $is_customized in this function
  return ($is_customized==true ? false : $is_purchasable);

So in your condition check the value of is_customized and pass the value to hook.No incompatibility issues would creep up.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.