Introduction

How To Disable Add to Cart Button in WooCommerce

WooCommerce is a powerful plugin for transforming your WordPress site into a fully-functional e-commerce platform.

Sometimes, you may need to disable the “Add to Cart” button for specific products or categories. Whether products are temporarily out of stock, you want a catalog without selling online, or you have other reasons, this guide will help you achieve your goal seamlessly.

Why Disable the “Add to Cart” Button?

Disabling the button can be useful in various situations:

  • Out of Stock: Prevent customers from purchasing items that are currently unavailable.

  • Catalogue Mode: Showcase your products without immediate purchase options.

  • Pre-launch Products: Display upcoming products to generate interest without selling yet.

  • Exclusive Products: Limit purchase options to certain user roles or members.

Methods to Disable the “Add to Cart” Button

1. Use a WooCommerce Plugin

The simplest way is by using a dedicated plugin.

Steps:

  1. Install and Activate: Search for a plugin like YITH WooCommerce Catalog Mode in the WordPress repository.

  2. Configure Settings: Enable catalog mode in the plugin settings. This disables the “Add to Cart” button site-wide or per selected category.

  3. Customize: Some plugins allow custom messages or actions when the button is disabled.

2. Use a Code Snippet for Specific Products

For a hands-on approach, you can add custom code.

Steps:

  1. Go to Appearance > Theme Editor in your WordPress dashboard. Open the functions.php file of your active theme.

  2. Add this code to disable the button for specific product IDs:

add_filter( ‘woocommerce_is_purchasable’, ‘carter_disable_add_to_cart’, 10, 2 );

function carter_disable_add_to_cart( $is_purchasable, $product ) {
// Define product IDs to disable the Add to Cart button
$disabled_product_ids = array( 123, 456 );

if ( in_array( $product->get_id(), $disabled_product_ids ) ) {
return false;
}

return $is_purchasable;
}

  1. Save changes. The button is now disabled for the specified products.

3. Disable for Out-of-Stock Products

WooCommerce has a built-in option for this:

  1. Go to WooCommerce > Settings > Products > Inventory.

  2. Ensure Enable stock management is checked.

  3. Check Hide out of stock items from the catalog.

4. Use CSS for a Quick Solution

For a temporary or design-specific fix, you can hide the button with CSS.

  1. Go to Appearance > Customize > Additional CSS.

  2. Add this code:

/* Hide Add to Cart Button */
.woocommerce .add_to_cart_button {
display: none !important;
}
  1. Click Publish to apply the changes.

Conclusion

Disabling the “Add to Cart” button can help you manage product availability and customer interactions strategically.

  • Plugins offer a simple, flexible solution.

  • Custom code gives precise control for specific products.

  • CSS is a quick and temporary fix.

Always back up your site before making code changes and test thoroughly to ensure everything works correctly.

By following these methods, you can confidently control your WooCommerce store’s functionality while maintaining a smooth shopping experience for your customers.

What should you do next?

Thanks for reading till the end. Here are 4 ways we can help you grow:

Want to learn more?

Explore our full collection of How-To guides to master every feature and functionality.

Check out How-To Guides →

Looking to grow your store?

Browse our WooCommerce plugins to discover tools that can improve performance and boost your sales.

Browse WooCommerce Plugins →

Curious about related topics?

Visit our blog for more tutorials, expert insights, and the latest trends in e-commerce.

Visit Our Blog →

Still confused about this topic?

Submit your question or contact our support team directly. We are here to help!

Contact Support Team →

Latest Articles

Shopping Cart