How to Hide/remove/disable Add to cart button in WooCommerce ?

Are you looking for a way to hide/remove/disable the Add to Cart button in your WooCommerce store? Perhaps you are not doing online sales and are only using WooCommerce as a product catalogue, or maybe you need your potential customers to contact you first before placing an order. Whatever your use case is, there are a few ways to tackle this problem.

In this article, we will discuss how to remove eCommerce functionality from your WooCommerce store, remove it only for certain product categories, or remove it for a single product.

Table of contents
Getting ready
Remove the “Add to cart” button completely
Remove the “Add to cart” button from a single product
Remove the “Add to cart” button from a product category
Use a plugin to remove the “Add to cart” button
Wrapping up

If you don’t want to mess with custom coding, don’t forget to check out
our free plugin: Remove Add to Cart WooCommerce
or consider upgrading to our premium plugin for more options!
Remove Add to Cart and Prices

Getting ready

Before doing any code modifications, it’s always a good idea to take a full backup of our site and make sure that we have FTP access or access to cPanel or Plesk or another control panel with access to a file manager.

If you wonder what is the best way to add code snippets to your site, have a look at our previous article about safely adding PHP code.

We assume that you already have WordPress with WooCommerce installed, and your store is displaying at least one product.

Remove the “Add to cart” button completely

With the following method, we will completely remove the Add to cart button from all products in our store.

As we see in the following screenshot, by default, WooCommerce adds the Add to cart button. This button is neither removable, nor customizable by default,so you cannot change the text, for example, or link it to a contact form instead of adding the product to the cart.

screenshot of defaut add to cart button

The button is also visible on the single product page, as well as the quantity field that allows the customer to choose the quantity to buy:

screenshot of defautl add to cart button in single product page

To remove this button, in our child theme’s functions.php file, or our site-specific plugin, all we need to do is add these two hooks:

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

If we now refresh the shop page, we can see that the button has been removed from all products:

screenshot of store with add to cart button removed

Additionally, both the Add to cart button and the quantity selection box has been removed from the single product page:

screenshot of single product page with add to cart button removed

Remove the “Add to cart” button from a single product

Sometimes the objective might not be to completely remove the cart button from our entire store. If you only need to remove the Add to cart button from a few products, here are some ideas on how to achieve this:

  1. Go to the selected products and empty the price fields.
    Simply go to the dashboard > “Products” > “All products” and access the “Quick edit” screen of your product:

screenshot of product quick edit screen

By emptying the price field, the product will no longer be available to add to cart:

screenshot of product without price

  1. Add a custom filter in your child’s theme’s functions.php file to mark the product as not purchasable. This will leave the product’s price visible, but remove the Add to cart button.

Here is the snipped to add in your functions.php file:

add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2);
function my_woocommerce_is_purchasable($is_purchasable, $product) {
        return ($product->id == <PRODUCT_ID> ? false : $is_purchasable);
}

For this to work, you have to replace <PRODUCT_ID> with your actual product ID. For example, to mark as not purchasable the following product:

screenshot of a product

We can see in the “All products” screen, when we hover over the product with the mouse”, that the product ID is 24. So the snippet would be:

add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2);
function my_woocommerce_is_purchasable($is_purchasable, $product) {
        return ($product->id == 24 ? false : $is_purchasable);
}

After using this snippet, the product will have the notice “Read more” in the store page:

screenshot of not purchasable product store page

While the price will be visible, but without a cart button on the single product page:

screenshot of not purchasable product single page

Remove the “Add to cart” button from a certain product category

Let’s say that we need to remove the cart button from all the products of a specific category while leaving it up for every other category. In order to achieve this, we will use the following snippet:

function my_function_remove_addtocart_category(){
   $product = get_product();

   if ( has_term( '<CATEGORY_SLUG>', 'product_cat') ){    
       remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
       remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
       remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
       remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
       remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
       remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
   }
}

add_action( 'wp', 'my_function_remove_addtocart_category' );

For this to work, we much replace <CATEGORY_SLUG> with the actual slug of our product category. Here is an example:

From the dashboard, if we go to “Products” > “Categories” we will see all the categories of our products and their slugs.

screenshot of product categories

Let’s say I want to remove the button from all products in the category hoodies. Then the above snippet would be:

function my_function_remove_addtocart_category(){
   $product = get_product();

   if ( has_term( 'hoodies', 'product_cat') ){    
       remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
       remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
       remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
       remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
       remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
       remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
   }
}

add_action( 'wp', 'my_function_remove_addtocart_category' );

Here is the result:

The products in the “hoodies” category do not display the Add to cart button:

screenshot of hoodies cateogory

While products in other categories keep the Add to cart option:

screenshot of music cateogory

Use a plugin to remove the “Add to cart” button

If you don’t want to mess with code snippets, or with manually emptying price fields, another option would be to use a plugin.

Our free plugin Remove Add to Cart WooCommerce is made specifically to help you remove easily the Add to cart button.

Once you install and activate the plugin, you can go to the product “Edit” page from your dashboard, and you will see a new option:

screenshot of plugin remove add to cart 1

By clicking on the “Remove cart button” option, you are presented with a drop-down that allows you to remove completely the button, or replace it with an “Inquire us” message.

screenshot of plugin remove add to cart 2

Choosing “Inquire us” will give you the option of linking to your contact page, which will redirect the customer so that they can contact you about the specific product.

You will also see the new option by going to any category “Edit” page – this way you can hide the button with a single click!

screenshot of plugin remove add to cart - categories

Wrapping up

In this article, we saw a few different use-cases where we would want to hide the Add to cart button for a certain category in WooCommerce, for a single product or for all the products.

This can be achieved manually, by adding the PHP snippets we show here, or by using our free plugin that does exactly this with a single click.

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

18 thoughts on “How to Hide/remove/disable Add to cart button in WooCommerce ?”

  1. Ronny Myhre Njaastad

    Hi

    If you put the code snippet in woocommerce.php it will dissapear next time you update WooCommerce.
    Better to put it in functions.php, or a stand-alone plugin.

Leave a Comment

Your email address will not be published. Required fields are marked *