How to Hide/remove/disable Add to cart button in woocommerce ? | themelocation

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

Free Plugin to Remove Add To Cart Button: Download at

Today we are going to do a bit of customization in the Woocommerce. Before, moving to the solution I assume that you have installed WordPress and Woocommerce on that successfully.

Now let’s move to the solution. When the problem came to me the first thought in my mind was to edit template files. That could be one approach but not a wise one for such a small customization.

After doing some research, I’ve came to the conclusion that luckily Woocommerce allows multiple hooks, with the help of these hooks, we can remove prices and buttons.

After installing WordPress go to backend and add a product. You can name it as you want and fill the details. See the image below:

Now on the front end you can see add to cart button on product listing i.e. shop page and product detail page as shown in the figures below.

Now we need to remove this button.

So, to remove add to cart button from product detail page and shop page i.e. product listing page all we need to do is to 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 );

We can place this code in any place where it should be appropriate.

In some cases, we can add them to functions.php file but in some cases it may generate some error. So, I’m going to place these hooks in woocommerce.php file under the plugins folder.

To access this file go to wordpress > wp-content > plugins > woocommerce and open the file woocommerce.php there and after line 904 place these two hooks.

Save the file then refresh page. Add to cart buttons should have been removed from the site.

Thats it.

How to remove the Add to Cart button from a specific product Only?

There are a couple of ways to do that, depending on the desired result:

1-  You could simply empty the price fields. The product will no longer have a price, nor an Add to cart button.
2-  You could enable stock management, and set the product stock to zero.
3-  You could write a filter for the “woocommerce_is_purchasable” hook, and return false when the product ID is the target one. This would leave the price visible, and display a “product cannot be purchased” note instead of the Add to cart button.

We will achieve the result by going with the Third option that is to add code to the functions.php file of the Child theme.

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


16 Responses to How to Hide/remove/disable Add to cart button in woocommerce ?

  1. Zain Jawaid November 1, 2015 at 5:25 pm #

    Thank You so much for This . It helped me a lot . Thanks

  2. Stephen November 12, 2015 at 4:41 am #

    Thanks. Worked perfectly

  3. Andrew Guild November 21, 2015 at 9:08 pm #

    This worked great. Thanks!

  4. Anup kumar November 25, 2015 at 11:50 am #

    ya its works !! thanks

  5. sudhi December 2, 2015 at 7:59 am #

    thanks so much.. it helps in my site , worked great!!

  6. Brenda Sargeant January 18, 2016 at 6:41 pm #

    Thank you for this! Worked perfectly 🙂

  7. techCherio February 1, 2016 at 10:53 am #

    thanx alot, great article

  8. dimitrios February 1, 2016 at 1:18 pm #

    Excellent! Many thanks…

  9. Ronny Myhre Njaastad February 26, 2016 at 10:22 am #


    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.

  10. John March 18, 2016 at 7:09 pm #

    Thank you so much! Saved me a ton of time.

  11. Alaina April 9, 2016 at 9:12 am #

    Its work. thanks a lot 🙂 !!

  12. Kumchu April 18, 2016 at 1:26 pm #

    helpful plugin thanks a lot

  13. Tom May 17, 2016 at 10:44 am #

    Hi, is it possible to hide the add to cart button on certain days of the week?

  14. Lucky E July 7, 2016 at 9:43 pm #

    thanks bro, great deal.

  15. Arnold September 28, 2016 at 9:58 pm #

    How can I remove the cart button but “keep the Price and variations”?

  16. Rafea September 24, 2017 at 2:56 pm #

    very helpful thank you

Leave a Reply