{"id":665,"date":"2019-11-05T07:15:52","date_gmt":"2019-11-05T07:15:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/11\/05\/hide-add-to-cart-button-in-magento-2\/"},"modified":"2025-07-17T10:39:59","modified_gmt":"2025-07-17T05:09:59","slug":"hide-add-to-cart-button-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/hide-add-to-cart-button-in-magento-2\/","title":{"rendered":"How To Hide Add To Cart Button in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are several reasons for doing so. For example,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Hide add to cart button for<strong> upcoming products<\/strong>: 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!<\/li>\n\n\n\n<li>Hide add to cart button for <strong>out of stock products<\/strong>: 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&#8217;t lose the conversion too!<\/li>\n\n\n\n<li>Hide add to cart button for <strong>specific products<\/strong>: Products that are only sample products or need to not be sold at the moment, implement the below solution.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Before:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/11\/Before-1024x619.png\" alt=\"\" class=\"wp-image-6802\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>After:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/11\/After-1024x618.png\" alt=\"\" class=\"wp-image-6803\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The below method to <em><strong>hide add to cart button in Magento 2<\/strong><\/em> disables it from product page as well as the category page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The solution is compatible with the latest <a href=\"https:\/\/meetanshi.com\/blog\/magento-2-4-8\/\">Magento 2.4.8 version<\/a>. So, make sure to <a href=\"https:\/\/meetanshi.com\/blog\/download-magento\/\" target=\"_blank\" rel=\"noreferrer noopener\">download the latest Magento version<\/a> and implement this solution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Hide Add To Cart button in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<em><strong>di.xml<\/strong><\/em>&nbsp;file in&nbsp;<strong>Vendor\\Module\\etc<\/strong>&nbsp;and copy the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns_xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi_noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"MagentoCatalogModelProduct\">\n        &lt;plugin name=\"hidebutton\" type=\"VendorModulePluginHideButton\" sortOrder=\"1\"\/>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<em><strong>HideButton.php<\/strong><\/em>&nbsp;file in&nbsp;<strong>Vendor\\Module\\Plugin<\/strong>&nbsp;and copy the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?phpnamespace Vendor\\Module\\Plugin;\nuse Magento\\Catalog\\Model\\Product;\nclass HideButton\n{\n    public function afterIsSaleable(Product $product)\n    {\n        return [];\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Run <strong><strong>php bin\\magento cache:clean<\/strong><\/strong> and refresh the page add to cart button will be vanished from category and product pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, you may opt for Meetanshi\u2019s <a href=\"https:\/\/meetanshi.com\/magento-2-call-for-price.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Call for Price<\/a> extension to hide the \u201cAdd to Cart\u201d 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with fellow developers via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-665","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=665"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":15196,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/665\/revisions\/15196"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}