_persistentSession = $persistentSession; $this->_persistentData = $persistentData; $this->_customerSession = $customerSession; $this->checkoutSession = $checkoutSession; } /** * Make persistent quote to be guest * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var $action \Magento\Persistent\Controller\Index */ $action = $observer->getEvent()->getControllerAction(); if ($action instanceof \Magento\Persistent\Controller\Index) { if (($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) || $this->_persistentData->isShoppingCartPersist() ) { $this->checkoutSession->clearQuote()->clearStorage(); } } } }