WooCommerce hide add to cart button for specific category (3 ways)

Hide add-to-cart button for specific category banner
Table of Contents

WooCommerce hide add to cart button for specific category is helpful when you want to guide users through a specific process before adding an item to their cart. It is also beneficial in some online stores with a wide variety of products that some of them in specific categories must be sold in person.

In this tutorial, we want to show you how to disable add to cart for certain category in WooCommerce with three methods:

Let’s review a step-by-step guide on how to use each method to better control the customer journey and create a seamless and intuitive user experience in your e-commerce store.

3 Methods for hiding Add to Cart for certain category in WooCommerce

WooCommerce disable add to cart for certain category could be achieved by using one of the below methods:

Hide add to cart button for a specific category by WooCommerce default

WooCommerce has one option for hiding the add to cart button on out-of-stock products.

When the products in a specific category are available in the store, the Add to Cart button is displayed as usual to them:

Product page without hide add to cart button

However, when the stock is zero, WooCommerce hides the add to cart button for specific product like this: 

Product page when add-to-cart button is hidden in WooCommerce

To make this happen, you need to follow the below steps:

  • Go to WordPress Dashboard > WooCommerce > Settings.
Open WooCommerce settings page
  • In the Settings page, open the Products tab. Then check the mark in front of Manage stock:

Once the “Manage stock” option is enabled, you may see other settings however they are not useful for the purpose of this tutorial.

Enabling manage stock in Inventory tab in WooCommerce settings
  • Press Save settings to enable Manage stock for all products.
  • Go to WordPress Dashboard > Products.
  • Open the Category filter dropdown list and choose one of the categories – Tiers in this example.
Filter products by category in WooCommerce
  • Hover over one of the products in this category and press the Edit option.
Click on product edit option
  • Go to the Product Data section. 
  • Mark Stock Management field.
  • Set Quantity to 0.
Manage product stock quantity in inventory section

You need to repeat these steps for all products in the specific category. So, all products that have 0 in their inventory will lose their add-to-cart button. 

If there are a large number of products that you need to set their stock quantity to 0, it makes sense to use the WooCommerce products bulk editing plugin and automate the process via bulk edit action for multiple products. It can help you to bulk edit WooCommerce product fields with one click so there is no need to open each product page individually and change the stock quantity manually.

Hide add to cart button manually in WooCommerce is not an ideal solution. It takes a lot of time and effort to open each product page one by one and set their stock value to 0.

So, let’s see how you can automate the process of the WooCommerce hide add to cart button for specific category. 

WooCommerce disable add-to-cart for certain category by coding

The second method for removing Add to Cart button from certain category is using the Php code and your theme’s function.php file.

Changing the `functions.php` file in a WordPress website is a powerful way to add custom functionality, but it comes with risks if not done carefully. 

That’s why website owners should take several precautions to ensure the process is smooth and to avoid potential issues. 

Here are the key steps to follow before making changes to the `functions.php` file:

  1.  Back Up the Website 

Any error in the `functions.php` file can cause the website to crash or malfunction.

So, use a reliable backup plugin (e.g., UpdraftPlus, Duplicator) or manually back up the website files and database to ensure the backup is stored in a secure location, such as cloud storage or an external drive.

  2.  Use a Child Theme 

 Directly editing the `functions.php` file in the parent theme can lead to loss of changes when the theme is updated. To prevent this from happening, you need to create and activate a child theme. Then, add custom code to the `functions.php` file in the child theme instead of the parent theme. This ensures that updates to the parent theme do not overwrite your customizations.

  1. Learn about coding or ask an expert to do it.

 Adding incorrect or poorly written code can break the website or introduce security vulnerabilities.

Try to research and understand the code snippet you plan to add. If you’re not confident, consult a developer or ask an expert to apply the code on your website.

      4. Use a Plugin for Custom Code

If you’re not comfortable editing the `functions.php` file directly, consider using a plugin like Code Snippets to add custom PHP code. This approach avoids editing theme files and makes it easier to manage and disable code snippets.

By considering these precautions, you can apply the following `functions.php` file safely and effectively:

add_action( 'WooCommerce _single_product_summary', 'remove_add_cart_button' );
/* Remove add to cart button */
function remove_add_cart_button() { 
// Categories
$categories = array( 'uncategorized' );
 if ( has_term( $categories, 'product_cat', get_the_id() ) ) {
remove_action( 'WooCommerce _single_product_summary', 'WooCommerce _template_single_add_to_cart', 30 );
 }
}

Once you have applied the code, the Add to Cart button of all products that belong to the ‘Uncategorized’ category will be removed.

Feel free to add multiple categories and separate them with a comma to remove the Add to Cart button of their products as well.

If using PHP code is not a useful option for your purpose and you need more flexibility for WooCommerce hide add to cart button for specific category, we recommend you to use the WooCommerce Hide Add to Cart and Price  plugin.

In the next part, we will show you how the plugin can make the process of WooCommerce disable add to cart for certain category more efficient.

WooCommerce hide add to cart button for a specific category by plugin

The most flexible method allowing you to hide the price and add to cart button of specific products or categories is the WooCommerce hide price and add to cart plugin.

It has many options for displaying a custom message instead of the Add to Cart button or even leading the customers to a specific link.

If you want to hide the add to cart button for specific category in WooCommerce, follow the three simple steps below:

Step 1: Install and Activate the WooCommerce Hide Price plugin

The first step is to download the Zip file and install it on your website.

Then try to activate it by going to WordPress Dashboard > iThemeland > License.

Open iThemeland plugins license page

And insert the License key in the form.

Activating WooCommerce hide price and add to cart plugin license
WooCommerce hide price and add-to-cart by user role

Now by navigating to the address below:

WordPress Dashboard > IThemeland > Hide Price

Open WooCommerce Hide price plugin

You are ready to hide the add to cart button for specific category, by following the next steps.

Step 2: Add Rule for WooCommerce hide add to cart button to specific category 

The process begins with adding a new rule. To make this, press the Add Rule button:

Add new rule in WooCommerce hide add to cart plugin

In the new form appeared you just need to fill in the following fields: 

  • Title: Add a title for the new rule to make it recognizable among others.
  • Apply rule to: In this field, you can specify for which user roles the add to cart button should be removed. You can choose:
    • Specific User role: You can assign the rule to the user roles that you have already defined in Wordpress like Contributor, Customer, Manager, etc.
    • Specific Customer: You can choose one or more customers (by the name that they have registered on your website before) to apply the rule.
    • Guests: You can apply the rule to the visitors who have not registered on your website, yet.
  • Select category: In this field, you can add one or more categories to let WooCommerce hide add to cart button for them. For example, we selected Tire category which means when guest users visit the products in the Tire category, the Add to Cart button will not displayed to them.
  • Hide Add to Cart button: Mark this field to disable add to cart for certain category. It is also possible to customize the button more via the two below options:
  • Customize button label: You can add any text in this field to show it instead of Add to Cart button. For example, we want to encourage customers to register before making a purchase. So, we replace the Add to Cart button with “Click to register”.
  • Custom button link: You can insert any URL in this field to lead customers to a specific link when click on the Add to Cart button. For example, we insert a registration link in this field, so, when customers click on the button, they will visit the registration page.
Set rule to WooCommerce hide add to cart button for specific categories

Finally, you can apply the rule by pressing the Add Rule button. 

It means when guest users visit any product from the Tire category, they will see the Click to Register button instead of the Add to Cart button.

result of hide add to cart button on tire category

Extra features of WooCommerce hide price plugin

The wooCommerce hide price plugin comes with many extra features to help you customize the WooCommerce hide Add to cart button for specific category rules.

Let’s review two of them briefly:

Feature 1: WooCommerce disable add to cart for certain category and specific role

Hiding the Add to Cart button for a specific role is an ideal solution for many online stores. They may hide the “Add to Cart” button for specific user roles to restrict purchasing capabilities, such as for wholesale accounts, guest users, or employees.

One of the amazing features of the WooCommerce hide price plugin is allowing store managers to apply any rule to specific user roles, customers, or guests.

Once you install the plugin, all user roles that you have defined in WordPress will be listed in the Rule for User roles field. So, you can easily choose any of them from the list to hide the add to cart button specifically for the selected role.

For instance, if you aim to hide the Add to Cart button just for Contributors, you can easily add Contributor to the field and apply the rule by clicking on the Save Changes.

Set hide add to cart rule for specific user roles

It means, that when customers, guests, or any other user role except contributors visit the products in the Tire category, they will see the Add to Cart button and they can proceed to checkout without registration.

However, if contributors want to order any product from the Tire category, they will see Click to register button. 

Feature 2: WooCommerce hide add to cart on a specific date 

Online stores may need to hide the “Add to Cart” button on specific dates to manage demand, prevent overselling, or promote exclusive sales events. 

To apply any rule on a specific date, you can easily use a built-in calendar designed in the Date field to set the Start and End date.

For instance, we tried to run the WooCommerce disable add to cart for certain category rules in January by setting the start date and end date to 1st and 31th Jan. 2025, respectively. 

Set hide add to cart rule on specific dates

As a result, contributors will see the Click to Register button when they visit any product pages belonging to the Tire category in January. The rule will be disabled automatically from 1st Feb. From then, the contributors will see the Add to Cart button, again.

Why use WooCommerce hide add to cart button for specific category?

Hiding the “Add to Cart” button for certain products or categories can be a great strategy for online stores to encourage customer engagement before shopping or improve stock management.

Here are six key reasons why this approach can be important:

  1.  Encourages customer engagement 

By hiding the “Add to Cart” button, online stores can encourage customers to engage more deeply with the brand. Removing the direct purchase option prompts customers to contact the store, or register to have access to the buying options.

It is also beneficial when customers need to ask questions or require additional information before making a purchase.  

  2.  Sell Products in person 

If the store provides some specific products that must be purchased only in person, it is important to hide Add to Cart button of those specific categories from the Online shop. 

The products in those categories cannot be sold with a simple click but require a buying process in person.

  3.  Improves Inventory Management 

For products with limited stock or high demand, hiding the “Add to Cart” button can help manage inventory more effectively. Instead of allowing customers to add items to their cart immediately, they can contact the seller and make sure that the products in a specific category are available to buy.

  4.  Enhances the Shopping Experience for Complex Products 

Some products, such as software, subscriptions, or customizable items, require additional steps before purchase. Hiding the “Add to Cart” button allows online stores to guide customers through a tailored buying journey. For instance, customers might need to select specific features, choose a subscription plan, or configure a product before proceeding to checkout. This approach ensures that customers fully understand what they are purchasing, reducing the risk of returns or dissatisfaction.

  5.  Builds Brand Exclusivity and Prestige 

Hiding the “Add to Cart” button can create a sense of exclusivity, resulting in increasing the perceived value of the product and driving demand.

In addition, by requiring customers to request access or contact the store directly, the brand positions itself as selective and high-end. 

This strategy appeals to customers who value exclusivity and are willing to invest time and effort into acquiring the product.

6. Restrict access of the general public to order specific category 

This can indicate either a restriction based on user type (thus creating exclusivity) or based on geographic location, with certain products or services unavailable outside certain areas.

It also allows the brand to maintain control over its image and customer base, ensuring that its products are marketed to the right audience.

WooCommerce hide price and add-to-cart by user role

Conclusion

Hiding the “Add to Cart” button is not about making the purchasing process more difficult; rather, it is a strategic decision that can benefit both the customer and the online store. By encouraging engagement, improving inventory management, enhancing the shopping experience, and building brand exclusivity, this approach can lead to higher customer satisfaction and increased sales. 

In this tutorial, we introduced three practical methods for WooCommerce hide add to cart button for specific category. Using default WooCommerce or custom coding to hide the “Add to Cart” button can be complex and time-consuming. WooCommerce hide price and add to cart button plugin, however, offers a user-friendly, efficient solution with built-in features and support. For most users, especially non-developers, this plugin is the best choice for seamless functionality and customization without technical hassle.