How to remove the Add to Cart button from a specific product Only?

Below are the ways to do that

  1. You could simply empty the price fields. The product will no longer have a price, nor an Add to cart button.
  2. You could enable stock management, and set the product stock to zero.
  3. You could write a filter for the “woocommerce_is_purchasable” hook, and return false when the product ID is the target one. This would leave the price visible, and display a “product cannot be purchased” note instead of the Add to cart button.

For the Third option use the below code in functions.php file of your theme:

Ankush chhabra

My name is Ankush Chhabra and I’m a 28 years old web developer and blogger.I have 5 years of experience in this field.

  • Sarah

    I want to adapt this code to make a whole list of specific products unpurchasable. I would add another filter but there is no common denominator between the products. Is there a cleaner way than using the ‘or’ operator between specific product IDs within the return function?

    id == 707 or 705 or 703 or 701 or 201 ? false : $is_purchasable);