How to hide add to cart button for particular products on all page in magento 2
To hide add to cart button all page using a below plugin:
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" /> </type> </config> HideButton.php
<?php namespace Vendor\Module\Plugin; use Magento\Catalog\Model\Product; class HideButton { public function afterIsSaleable( \Magento\Catalog\Model\Product $subject, $result ) { if($subject->getId() == 36) { return false; } else { return true; } } } Above plugin works well but its shows an "Out of Stock" instead of "Add to cart" in listing and home page how to hide a "out of stock" text.
