How to Hide Add To Cart Button in Magento 2?

How To Hide Add To Cart Button in Magento 2

Are you looking to hide Add to cart button in Magento 2 store?

Magento 2 is a powerful ecommerce platform with plenty of valuable features. You can do many customizations within the dashboard.

For example:

But for some customization, like hiding the Add to Cart button, you have to add several lines of code to the store.

In this quick tutorial, I will show you how to hide Add to Cart button in Magento 2.

Why hide Add to Cart button?

Though, showing Add to Cart button is critical and necessary for the success of the ecommerce store. In fact it is a prominent call to action button.

However, hiding Add to Cart button is helpful in many scenarios. Some reasons are:

Product Out of Stock: If the product is not in inventory, you would like to show the β€˜notify me’ button instead of the Add to Cart button. Notify button to provide an option to the customer to get a notification when the product arrives.

Custom Pricing: Sometimes, the product does not have any fixed cost. There are too many variables involved that you have to give custom quotations. Magento owners can show the Request Quote button in place of the Add to cart button.

Login Users: Few ecommerce niche stores have the standard practice of showing the pricing only to the login users. If the user is not registered and logged in, the Add to Cart button will stay hidden. 

To execute any scenario, you will have to hire a Magento developer. These actions require coding and custom-built modules.

However, to hide Add to Cart button, you can do it yourself by following this tutorial.

How to hide Add to Cart button in Magento 2?

Step 1: Navigate to this path – Vendor\Module\etc

Step 2: Create a di.xml file

<?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="Magento\Catalog\Model\Product">
        <plugin name="hidecartbutton" type="Vendor\Extension\Plugin\Hidecartbutton" sortOrder="32"/>
    </type>
</config>

Step 3: Navigate to the Vendor\Module\Plugin path

Step 4: Create a HideButton.php file

<?php

namespace Vendor\Extension\Plugin;

use Magento\Catalog\Model\Product;

class Hidecartbutton
{
    public function afterIsSaleable(Product $product)
    {
        return [];
    }
}

Step 4: Finally, clean the Magento cache and clear the Redis cache.

Check the store front end to find that the Add to Cart button is not there anymore.

Wrap Up

Scarcity is a marketing tactic that uses FOMO to promote a product.

If the customer does not see an Add to Cart button, it will intrigue them to take action to know the pricing of the product. 

In this quick tutorial, we learn how to hide the Add to Cart button. If you encounter any issues, please leave them in the comment section.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

πŸŽ‰ CYBER MONDAY SAVINGS πŸŽ‰

75% OFF on
ALL PLANS

Receive the coupon as soon as you
submit the email address. πŸš€