How to Hide, Remove or Disable Add to Cart Button in WooCommerce Store

by Owais Alam  February 14, 2017

In this tutorial, I will discuss an important aspect of WooCommerce shop page customization. As always, I assume a working WooCommerce store (preferably on Cloudways. If not, sign up for your free trial).

I will now discuss how to hide, remove or disable the Add to Cart button on WooCommerce shop pages. Initially, I thought that the solution of these related challenges was to edit the template files. however, I soon realized that this would be an overkill for such a simple task!

Hide, Remove or Disable Add to Cart Button in WooCommerce Store

After some research, I realized that WooCommerce offers several hooks that could be utilized for removing the buttons and prices from various pages.

To demonstrate the process, first go to the WooCommerce store and add a product. Give it a name and try to fill as much details as possible for this test product.  For help. please consult the following screenshot:

go to the WooCommerce store and add a product

In the frontend of the store, you will now see the product detail page (consult the screenshot below). I have circled the Add to Cart button in red!

Add to Cart button in red

Hide or Disable the Add to Cart Button

I will now demonstrate how to remove this button from product detail page and the shop page (product listing page). For this, I will add the following hooks:

The good thing about these hooks is that you could place them anywhere appropriate. The common practice is to include these hooks in functions.php which is located in your theme folder. However, this might cause errors in some cases. I will, therefore, place these hooks in woocommerce.php (found in the plugins folder). To access this file, of to WordPress > wp-content > plugins > woocommerce > woocommerce.php.

Once done, save the file and refresh the page. Once the page loads, you will see that the Add to Cart button has been removed from the page.

Add to Cart button has been removed from the page.

Remove Add to Cart Button for Specific Products

There are times when you wish to remove the Add to Cart button from specific product pages. There are three ways of achieving this objective:

The first option is to simply remove the figure from the price fields. The product no longer has a price, and consequently the Add to Cart button.

The second option is to enable stock management and then set the product stock to zero.

Finally, the third option is to write a filer for the woocommerce_is_purchasable hook. Every time this filter detects the product id of the target product, it will return false. The result is that the price will be visible but in the place of Add to Cart button, a notice “Product cannot be purchased” will appear.

I will go with the third option, by adding the following code to functions.php (located in the theme folder).

Conclusion

In this tutorial, I discussed how to hide, remove and disable Add to Cart button on WooCommerce product pages. The process is very simple and the results could be cleanly achieved by adding small snippets of code at the proper locations. If you need further help or would like to contribute to the discussion, of leave a comment below.

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at owais.alam@cloudways.com

Stay Connected:

You Might Also Like...