This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

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

Updated on  14th February

3 Min Read
Hide, Remove or Disable Add to Cart Button in WooCommerce Store
Reading Time: 3 minutes

In this tutorial, I will discuss the important aspect of WooCommerce shop page customization that results in better-customized user experience. As always, I assume that you have a working WooCommerce store with optimized settings (preferably on Cloudways. If not, sign up for your free trial).

Before you can customize Woocommerce store, the first thing you need to do is install WooCommerce plugin. You can download it for free from the WordPress repository or follow this guide how to do it from your dashboard.

I will now discuss how to hide, remove or disable the Add to Cart button on WooCommerce shop pages. There are many reasons why WooCommerce store owner can temporarily or permanently disable add cart button on their website, for instance, a product is out of stock. 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!

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 many 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. No matter which WooCommerce theme you are using, the above mention method of removing Add cart button will be applicable. If you need further help or would like to share some other method leave a comment below.

Share your opinion in the comment section. COMMENT NOW

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

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.