General

How To Hide Add To Cart Button in Magento 2

Howdy Magento Folks?,

What’s going on? I hope all are reading up with good health. Let’s start with today’s topic How To Hide Add To Cart Button in Magento 2. Don’t miss our previously published article How to Enable Persistent Shopping Cart in Magento 2. Let’s Dive In?

Introduction:

Mainly, the Magento 2 store owners always allow their users to add products at the cart for the checkout process. Many times the store owners have their individual rules of adding products for checkout. For example, there are products that are upcoming in the store then obviously there is a requirement to hide the add to cart or Request for Quote button in Magento 2. Sometimes the store owner wishes to hide the price and add a cart button then Solve this problem by integrating MageComp’s Magento 2 Hide Product Price extension. Let’s hide the add to cart button in Magento 2 also for restricting the users not to display until and unless they are not Logged In. Let’s start.

Steps to Hide Add To Cart Button in Magento 2:

Step 1: Firstly Create a di.xml file at the given below path.

Vendor\Module\etc

<?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 2: Now, Create HideButton.php file at the given below path 

Vendor\Module\Plugin

<?php

namespace Vendor\Extension\Plugin;


use Magento\Catalog\Model\Product;


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

Step 3: Now, just run php bin\magento cache:clean and refresh the page and you will realize the add to cart button will be hidden from your store pages.

Final Words:

Hopefully, all are able to hide the add to cart button from your Magento 2 Store but incase any difficulties then do contact MageComp Support. Also, share with your developer friends for helping them in solving the hide add to cart button in Magento 2. Do share your reviews with us in the comment section below.

Happy Coding?

Click to rate this post!
[Total: 3 Average: 3.7]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

5 hours ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

2 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

2 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

3 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

4 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

6 days ago