You can Hide or Remove the Add to cart button of the WooCommerce plugin by using any of the steps that we have listed below.
- Removing the Add to cart means we are assuming you do not have a price for the given products. So simple in the admin panel move to the price field and stay it empty.
- You can enable stock management in the admin and you need to set the stock value to Zero.
- You can write a filter
woocommerce_is_purchasableand return false when the product ID is the target one. By adding the WordPress hook in thefunctions.phpfile the price will be visible on the frontend and shows a Product cannot be purchased instead of the Add to cart button.
The below code can be used in the functions.php file for the third example.
add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2);
function my_woocommerce_is_purchasable($is_purchasable, $product) {
return ($product->id == whatever_mambo_jambo_id_you_want ? false : $is_purchasable);
}
You can Remove or Hide the Add to Cart button from a specific product by using WooCommerce shortcodes.