Add to cart: How to disable this button in Magento 2

Add to cart

Although disabling add to cart button is not recommended and should be avoided because it may hurt your profit. However, in some particular situations, store owners put products on display without selling for specific reasons, and they need to disable this very important button. Hiding the Add to cart button in Magento 2 store can restrict the customers to add products to the cart.

The Purpose of Disabling the Add To Cart Button

There are several reasons for disabling the Add To Cart button. For example,

  • Upcoming products: Disable add to cart button for upcoming items. You are working on some items or software. But you want to take advantage of SEO keywords and not yet actually provide the product. At that time, you can show the items but hide the add to cart button. Doing so, you can generate the hype and also restrict the customers to add them to the cart!
  • Out of stock products: If you are selling items that are currently out of stock and users are seeking for it, you can use the disabling add to cart solution. And also, you can help users to subscribe to that item for a notification when the product is on the stock with further customization. Therefore, you won’t lose the conversion.
  • Specific products: Hide add to cart button for specific products that are only sample products or need to not be sold at the moment
  • Reference or non-selling products: With the purpose of driving potential customers to target products, the admin wants to recommend other relevant products but not sell them. Users can view more details and compare the functions of the items before making purchasing decisions.

Show on the product listing:

Add to cart

Show on the Product Page:

Add to cart

Manually Disable Add to Cart Button with Code

The following solution will allow you to disable add to cart button in Magento 2 from the product page as well as the category page. The method is compatible with the latest Magento 2.3.5 version. So, you need to download the latest Magento version for this solution.

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

<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="/lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
 <type name="Magento\Catalog\Model\Product">
 <plugin name="hidebutton" type="Vendor\Module\Plugin\HideButton" sortOrder="10" disabled="false" />

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

namespace Vendor\Module\Plugin;
use Magento\Catalog\Model\Product;
class HideButton
 public function aroundIsSalable(Product $product,\Closure $result)
 return 0;

3. Run php bin\magento cache:clean to clear cache and refresh the page.

Now, all the products which filed under the associated category will display prices but add to cart button will keep disabled. This combine with hiding the add to cart button from the catalog, the home page, product detail page, and every other page where you might have enabled your shoppers to add to cart.

Note: If you want to hide add to cart button completely, you need to configure Call for Price tab.

  • Add to Phrasebook
    • No word lists for English -> Vietnamese…
    • Create a new word list…
  • Copy
144 Total Views 4 Views Today