Hide Add to Cart Button

Just add the following code in your functions.php and you will find button hidden

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 checkbox value in this function
 // let $checkbox_value be the value from checkbox
  return ($checkbox_value == false ? false : $is_purchasable);
}

No incompatibility issues would creep up.

Leave a Comment