I am trying to hide add to cart button. Need help

Posted In PHP
  • suthana-alley 2 years ago
    I am trying to hide add to cart button in Magento 2 as i have implemented all the steps that i have seen in the tutorial [https://magenticians.com/hide-add-to-cart-guest-users-magento-2/](https://magenticians.com/hide-add-to-cart-guest-users-magento-2/) but still the button is not hidden. Can any one guide me on this ?
    <code>
    use Magento\Framework\Event\Observer;
    use Magento\Framework\Event\ObserverInterface;
    use Magento\Customer\Model\Session as CustomerSession;
    
    class AddHandles implements ObserverInterface
    {
        protected $customerSession;
        public function __construct(CustomerSession $customerSession)
        {
            $this->customerSession
        }
    
        public function execute(\Magento\Framework\Event\Observer $observer)
        {
            $layout = $observer->getEvent()->getLayout();
    
    //To check that customer is logout
            if (!$this->customerSession->isLoggedIn())
            {
                $layout->getUpdate()->addHandle('customer_logged_out');
            }
        }
    }
    </code>

    I am trying to hide add to cart button in Magento 2 as i have implemented all the steps that i have seen in the tutorial https://magenticians.com/hide-add-to-cart-guest-users-magento-2/ but still the button is not hidden. Can any one guide me on this ? use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Customer\Model\Session as CustomerSession;

    class AddHandles implements ObserverInterface { protected $customerSession; public function __construct(CustomerSession $customerSession) { $this->customerSession }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $layout = $observer->getEvent()->getLayout();
    

    //To check that customer is logout if (!$this->customerSession->isLoggedIn()) { $layout->getUpdate()->addHandle('customer_logged_out'); } } }

  • devdojo 2 years ago
    Hi @suthana-alley
    
    I would love to try and help out, but I'm not too familiar with Magento. But I'll make sure to put it on my list of things to learn so that way I could help you out later on down the road :)

    Hi @suthana-alley

    I would love to try and help out, but I'm not too familiar with Magento. But I'll make sure to put it on my list of things to learn so that way I could help you out later on down the road :)

  • xander-neon 4 months ago
    There are a lot of free plugins available which you can use for this pupose and add a cat button easily. You get these plugins [boom essays](https://www.essayuniverse.net/boomessays-review/) and they record videos on each plugin features and how you use them.

    There are a lot of free plugins available which you can use for this pupose and add a cat button easily. You get these plugins boom essays and they record videos on each plugin features and how you use them.

  • micah-james 3 months ago
    Well, normally add to cart button code is available online which you just copy and paste to your file. You can change the color and design according to your needs and requirments. [http://astarios.com/big-data-analytics/](https://astarios.com/big-data-analytics/)

    Well, normally add to cart button code is available online which you just copy and paste to your file. You can change the color and design according to your needs and requirments. http://astarios.com/big-data-analytics/

  • solar-system 13 hours ago
    thank you for sharing this content, also visit site [https://www.futuresolarwa.com.au/](http://)

    thank you for sharing this content, also visit site https://www.futuresolarwa.com.au/

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!