How To Hide Add To Cart Button in Magento 2

How To Hide Add To Cart Button in Magento 2 4

Magento 2 stores allow the users to add products to cart for checkout. However, there may be scenarios where the store owner may want to restrict this action. Disabling add to cart button in Magento 2 store can restrict the users to add products to the cart.

There are several reasons for doing so. For example,

  • Hide add to cart button for upcoming products

    You are working on some products or software. But you want to start having the SEO benefit of the keyword and not yet actually offer the product. At that time, you can offer the products but disable the add to cart button. Doing so, you can create the hype and also restrict the users to add them to the cart!

  • Hide add to cart button for out of stock products

    If you are selling products that are currently out of stock and people are looking for it, you can implement the below solution. And also, you can allow them to subscribe to that product for a notification when the product gets back in stock with further customization. Hence, you won’t lose the conversion too!

  • Hide add to cart button for specific products

    Products that are only sample products or need to not be sold at the moment, implement the below solution.

Before:

How To Hide Add To Cart Button in Magento 2 5

After:

How To Hide Add To Cart Button in Magento 2 6

The below method to hide add to cart button in Magento 2 disables it from product page as well as the category page

Method to Hide Add To Cart button in Magento 2:

  1. Create di.xml file in Vendor\Module\etc and copy the below code
  2. Create HideButton.php file in Vendor\Module\Plugin and copy the below code
     
  3. Run php bin\magento cache:clean and refresh the page add to cart button will be vanished from category and product pages.

That’s it.

Any doubts on how to remove add to cart button in Magento 2 store can be mentioned in the Comments section below and I’ll be happy to help.

Feel free to share the solution with fellow developers via social media.

Thanks.

5
(based on 3 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply