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.

Every 1 second delay costs up to 20% conversions. Learn how to fix it [Free • Mar 10–11]. Save My Spot→

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

Updated on August 26, 2025

7 Min Read
woocommerce add to cart button hide remove or disable

Key Takeaways:

  • Controlling the “Add to Cart” button in WooCommerce allows for greater flexibility in managing product displays and sales, catering to various scenarios like out-of-stock items or catalog-only products.
  • Hiding the button makes it invisible to users, while removing it completely eliminates it from the site’s code, offering different levels of control.
  • Conditional hiding or removal based on product IDs or other criteria provides granular control over which products are available for purchase.
  • Disabling the button keeps it visible but unclickable, signaling product unavailability without completely removing the purchase option.

There are plenty of reasons you might want to hide, remove, or disable the add-to-cart button on your WooCommerce store. Perhaps the product displayed in your store is not on sale, or you want to show the product catalog or your products have gone out of stock.

That’s why you need greater customizability to update your store’s functionality per your demands. A huge repository of WordPress plugins and WooCommerce extensions offers users extensive customization options that result in a more user-friendly experience.

In this article, I will show you how to hide, remove, or disable the add-to-cart button on your WooCommerce store, catering to out-of-stock scenarios or product catalog displays. You can use managed WordPress hosting by Cloudways to host your WooCommerce store.

Why Hide, Remove, or Disable the ‘Add to Cart’ Button?

The ‘Add to Cart’ button is a crucial component of any WooCommerce store.

It’s the gateway between browsing and buying, serving as the first step in the customer’s purchasing journey. But there might be scenarios where you want to hide, remove, or disable this button.

Perhaps you’re running a catalog site with no direct purchases or want to make certain products viewable but not purchasable. Whatever your reason, understanding how to manipulate this button gives you greater control over your store’s functionality.

Understanding the Difference Between Hiding and Removing

While hiding the ‘Add to Cart’ button makes it invisible, removing it entirely deletes the button from your site’s code. This means that even if someone inspects your site’s code, they won’t find the button. This can be useful if you want to prevent savvy users from bypassing your store’s intended flow.

💡 Note: Before making any changes, ensure your WooCommerce site is backed up. If anything goes wrong, you can restore your store to its previous state.

Keep your WooCommerce store fast and user‑friendly

Learn performance insights that prevent slowdowns when customizing cart behavior.

Mar 10–11 | Free & Live

Hide Add to Cart Button From WooCommerce Product Page

Let’s start with removing the ‘Add to Cart’ button from both the product detail page and the shop page (product listing page). To implement this, I will use the following 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');

You can insert these hooks wherever you find suitable. Typically, these hooks are added to the functions.php file located in your theme folder.

However, in some instances, this might lead to errors. Therefore, I recommend placing these hooks in the woocommerce.php file located in the plugins folder.

Here are the steps to access the woocommerce.php file:

  • Navigate to WordPress → wp-content.
  • Click on Plugins → WooCommerce → woocommerce.php.

Next, add the following code:

/**

 * Main instance of WooCommerce.

 *

 * Returns the main instance of WC to prevent the need to use globals.

 *

 * @since  2.1

 * @return WooCommerce

 */

function WC() {

    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');

    return WooCommerce::instance();

}

After adding the code, save the file and refresh your page. If done correctly, you should see that the ‘Add to Cart’ button has been removed from your page.

img

Hide WooCommerce Add to Cart Button Conditionally

There may be instances where you only want to hide the ‘Add to Cart’ button for specific products. In such cases, a conditional approach is required.

Hide Woocommerce Add to Cart button for a Specific Product

Follow these steps to hide the ‘Add to Cart’ button for a specific product:

  • Navigate to WordPress Dashboard → Products → All Products.
  • Hover over the product for which you want to hide the ‘Add to Cart’ button and note down the product ID (in this example, the ID is 25).

product ID

Next, add the following code to your functions.php file:

add_action( 'woocommerce_after_shop_loop_item', 'hide_add_to_cart_for_specific_product', 10 );

function hide_add_to_cart_for_specific_product() {

    global $product;

    if ( 25 == $product->get_id() ) {

        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 );

    }

}

hide button

With this code, the ‘Add to Cart’ button will be hidden for the product with ID 25. In this case, it’s a customizable mug.

Drive Your Online Store’s Growth with Autonomous!

“Step into the future of hosting with Cloudways Autonomous. Experience seamless scalability, unmatched speed, and ironclad security for your website.”

Hide Woocommerce Prices on the Shop and Category Pages

To remove WooCommerce prices on the shop and category page, you need to open the functions.php file and add the following code;

remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );

By adding this code, you remove the product price on the shop and category pages. Here’s the result:

result

Remove the Add to Cart Button for Specific Products

There are three methods to remove the ‘Add to Cart’ button from specific product pages:

  1. Remove the value from the price fields. This will result in the product no longer having a price, which in turn removes the ‘Add to Cart’ button.
  2. Enable stock management and set the product stock to zero.
  3. Use the filter for the woocommerce_is_purchasable hook.

Use woocommerce_is_purchasable Hook

I will use a filter that targets a specific product ID for which I want to remove the ‘Add to Cart’ button.

Whenever this filter identifies the product ID of our target product, it will return false. As a result, while the price will still be visible, a notice will replace the ‘Add to Cart’ button stating, “Product cannot be purchased”.

To implement this, add the following code to your functions.php file.

add_filter('woocommerce_is_purchasable', 'woocommerce_cloudways_purchasable');

function woocommerce_cloudways_purchasable($cloudways_purchasable, $product) {

return ($product->id == your_specific_product_id (like 22) ? false : $cloudways_purchasable);

}

Disable Instead of Hide or Remove Add to Cart Button

Disabling the ‘Add to Cart’ button differs from hiding or removing it.

When you disable the button, it remains visible but becomes unclickable. This can be useful if you want to show that a product is normally available but is currently out of stock or unavailable for other reasons.

Here’s how you can disable the ‘add to cart’ button with a custom code:

  • Navigate to Appearance → Theme Editor and find the functions.php file.
  • Add the following code to disable the ‘Add to Cart’ button:
add_filter( 'woocommerce_is_purchasable', 'disable_add_to_cart_button' );

function disable_add_to_cart_button( $is_purchasable ) {

    // You can add conditions here to disable the button for specific products

    return false; // return false disables the 'Add to Cart' button

}
  •  Click ‘Update File’ to save your changes.

Now, the ‘Add to Cart’ button should be disabled on your WooCommerce store. Remember, this will prevent customers from adding items to their cart, so ensure this aligns with your store’s strategy.

Host Your WooCommerce Stores on our WordPress Servers for a hassle-free experience!

Forget hosting management and enjoy lightning-fast performance results with Cloudways managed hosting. Focus solely on growing your brand.

Summary

In this blog post, we’ve unlocked the power of WooCommerce by mastering the ‘Add to Cart’ button. I’ve shown you how to hide, remove, or disable it, each with its own unique benefits.

I encourage you to try these methods and see the difference they can make in your store. Whether you’re looking to streamline your catalog or manage product availability, these techniques offer a new level of control. You can use managed hosting for WooCommerce stores offered by Cloudways for fast and scalable eCommerce stores.

So why wait? Dive in and start customizing your WooCommerce store today!

Q. How do I disable the add to cart button in WooCommerce?

A. You can disable the add to cart button by adding a code snippet to your theme’s functions.php file. Use the following code to remove the button from single product pages:

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

For site-wide removal, additional conditions can be applied to target specific products or categories.

Q. How do I remove the shopping cart icon in WooCommerce?

A. To remove the shopping cart icon, add the following CSS to your theme’s Customizer or style.css file:

.woocommerce-cart .cart-contents { display: none; }

This hides the cart icon from the navigation menu.

Q. How do I change the add to cart button in WooCommerce?

A. To modify the add to cart button text, add this filter to your functions.php file:

add_filter('woocommerce_product_add_to_cart_text', function() { return 'Your Custom Text'; });

For further customization, adjust the button’s CSS or modify its HTML structure.

Q. How do I clear the cart button in WooCommerce?

A. You can programmatically clear the WooCommerce cart using this snippet:

WC()->cart->empty_cart();

This can be added to a custom button or triggered by a specific event to empty the cart when needed.

Q. How to hide the add to cart button in WooCommerce?

A. To hide the add to cart button, use CSS:

.add_to_cart_button, .single_add_to_cart_button { display: none; }

For dynamic control, use a PHP function to remove it conditionally.

Q. How do I remove the add to cart button in WooCommerce?

A. You can remove the add to cart button site-wide or on specific pages by modifying functions.php. For example, to remove it from product archives:

remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);

Q. How do I disable the cart page in WooCommerce?

A. To disable the cart page, redirect users to another page using this function in functions.php:

function disable_cart_page_redirect() {
        if (is_cart()) {
            wp_redirect(home_url());
            exit;
        }
    }

This ensures users cannot access the cart page.

Q. Can I remove the add to cart button on Shopify?

A. Yes, Shopify allows removing the add to cart button by editing the theme’s product-template.liquid file. You can comment out or delete the <form> that contains the add to cart button, or use CSS to hide it.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Sarim Javaid

Sarim Javaid is a Sr. Content Marketing Manager at Cloudways, where his role involves shaping compelling narratives and strategic content. Skilled at crafting cohesive stories from a flurry of ideas, Sarim's writing is driven by curiosity and a deep fascination with Google's evolving algorithms. Beyond the professional sphere, he's a music and art admirer and an overly-excited person.

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour