
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 tutorial, I will show you how to hide, remove, or disable the add to cart button on WooCommerce stores.
Add Products to WooCommerce
You must have products in your store to get the add to cart functionality. Therefore, I’ll first show you how to add products to your WooCommerce Store.
- Go to WooCommerce Dashboard.
- Click Products → Add products.
- Name the product and fill in the details.
Note: For help, please consult the following screenshot.
- You will see the product detail page with the add to cart button on your store’s front end.
This is how you add products to your store.
Try out WooCommerce customization on Cloudways hosting!
Our platform allows for easy customization of your WooCommerce store, giving you the ability to create a personalized shopping experience.
Hide or Disable Add to Cart Button
I will now demonstrate how to hide or disable the add to cart button from the product detail page and the shop page (product listing page). For this, I will add 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 place these hooks anywhere you deem appropriate. The common practice is to include these hooks in functions.php, 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).
Follow the steps below to access the woocommerce.php file:
- Go to WordPress → wp-content
- Click Plugins → WooCommerce → woocommerce.php
/** * 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(); }
- Once done, save the file and refresh the page.
Congratulations! The add to cart button has been removed from the page.
Remove Add to Cart Button for Specific Products
There are three specific ways to remove the add to cart button from specific product pages:
- Remove the figure from the price fields. The product will no longer have a price, removing the add to cart button.
- Enable stock management and set the product stock to zero.
- Use the filter for the woocommerce_is_purchasable hook.
Use woocommerce_is_purchasable Hook
We will set the filter that only includes the particular product-id from which we wish to remove the add to cart button.
Every time this filter detects the product id of the target product, it will return false. Thus, the price will be visible, but a notice will appear in place of the add to cart button that says, “Product cannot be purchased”.
I will use the third option by adding the following code to functions.php (located in the theme folder).
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); }
Summary
In this tutorial, I showed hiding, removing, and disabling the add to cart button on WooCommerce product pages. The process is simple and can be implemented by adding small code snippets at the proper locations. You may use the methods mentioned in this blog to remove the add to cart button regardless of your WooCommerce theme. If you need further help with this, please leave a comment below.
Frequently Asked Questions
Q: How do I get rid of the Add to Cart option?
A: There are three ways to eliminate the add to cart button on a WooCommerce store.
- Remove the figure from the price fields.
- Enable stock management and set the product stock to zero.
- Set “WooCommerce-is-purchasable” to false for the specific product id.
Q: How do I remove the update cart button in WooCommerce?
A: Follow the steps below to remove the update cart button on your WooCommerce store:
- Open your theme’s function.php file.
- Make a hook function to add all the above code in the website’s header or footer.
- Add the function “codedocx_update_cart_button()” to your active theme’s function.php file.
- Save the changes.
Q: How do I edit the add to cart button in WooCommerce?
A: Edit the add to cart button on WooCommerce by following the steps below:
- Install the WooCommerce Custom Add to Cart Button plugin on your WordPress site.
- Go to Appearance → Customizer → WooCommerce → Add to Cart.
- Choose the relevant setting, such as changing color or text.
- Click the Publish button.
Q: How do I disable the WooCommerce cart?
A: Disable the WooCommerce cart by following the steps below:
- Open functions.php file.
- Include the following hook.
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');
Q: How do I hide the shopping cart in WooCommerce?
A: Following the steps below will hide the shopping cart on WooCommerce.
- Go to your WordPress Dashboard
- Select Appearance → Customize → WooCommerce → General → Menu Cart
- Uncheck the Menu Cart: Display
Q: How do I get rid of the Buy Now button in WooCommerce?
- Go to WooCommerce Dashboard.
- Click Settings → Payments → Stripe
- Uncheck the “Enable payment request buttons”.
Customer Review at
“Great performance for the price, and plenty of control”
Sean P [SMB Owner]
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 [email protected]