Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to hide add to cart button ?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #266908
    suthanalley
    Participant

    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 ?

    When i was creating a file apphandles.php i found several issues but i resolve it but still just go through it. Did i done something wrong here ? Why i am not having the right output ?

    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');
            }
        }
    }
    
    #266909
    grimslayer
    Participant

    Hey,

    Did you run the cli commands at the bottom without any errors on the command line?

    You could also try this command:

    php bin/magento setup:static-content:deploy en_GB

    instead of:

    php bin/magento setup:static-content:deploy

    Let me know if you still have issues after this.

    #266910
    grimslayer
    Participant

    You might also have to run the enable module command first:

    php bin/magento module:enable Magenticians_Mymodule

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.