🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How To Hide Add To Cart Button in Magento 2

By Sanjay JethvaUpdated on Jul 17, 2025 3 min read

Magento 2 stores allow the users to add products to the 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:

After:

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

The solution is compatible with the latest Magento 2.4.8 version. So, make sure to download the latest Magento version and implement this solution.

Method to Hide Add To Cart button in Magento 2:

1. Create di.xml file in Vendor\Module\etc and copy the below code:

<?xml version="1.0"?>
<config xmlns_xsi="http://www.w3.org/2001/XMLSchema-instance" xsi_noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCatalogModelProduct">
        <plugin name="hidebutton" type="VendorModulePluginHideButton" sortOrder="1"/>
    </type>
</config>

2. Create HideButton.php file in Vendor\Module\Plugin and copy the below code:

<?phpnamespace Vendor\Module\Plugin;
use Magento\Catalog\Model\Product;
class HideButton
{
    public function afterIsSaleable(Product $product)
    {
        return [];
    }
}

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.

Or, you may opt for Meetanshi’s Magento 2 Call for Price extension to hide the “Add to Cart” button and product prices on the front end. The visitors can call you for pricing inquiries and thus improve the quotation system in your Magento 2 store.

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

Thanks.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.