/** * Dispatch request * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface * @throws \Magento\Framework\App\Action\NotFoundException */ public function dispatch(RequestInterface $request) { $this->_request = $request; $this->_preDispatchValidateCustomer(); /** @var \Magento\Sales\Model\Quote $quote */ $quote = $this->_objectManager->get('Magento\\Checkout\\Model\\Session')->getQuote(); if ($quote->isMultipleShippingAddresses()) { $quote->removeAllAddresses(); } if (!$this->_canShowForUnregisteredUsers()) { throw new NotFoundException(); } return parent::dispatch($request); }
/** * Dispatch request * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface * @throws \Magento\Framework\Exception\NotFoundException */ public function dispatch(RequestInterface $request) { $this->_request = $request; $result = $this->_preDispatchValidateCustomer(); if ($result instanceof \Magento\Framework\Controller\ResultInterface) { return $result; } /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->_objectManager->get('Magento\\Checkout\\Model\\Session')->getQuote(); if ($quote->isMultipleShippingAddresses()) { $quote->removeAllAddresses(); } if (!$this->_canShowForUnregisteredUsers()) { throw new NotFoundException(__('Page not found.')); } return parent::dispatch($request); }
/** * Dispatch request * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(RequestInterface $request) { $this->_request = $request; if ($this->_actionFlag->get('', 'redirectLogin')) { return parent::dispatch($request); } $action = $request->getActionName(); $checkoutSessionQuote = $this->_getCheckoutSession()->getQuote(); /** * Catch index action call to set some flags before checkout/type_multishipping model initialization */ if ($action == 'index') { $checkoutSessionQuote->setIsMultiShipping(true); $this->_getCheckoutSession()->setCheckoutState(\Magento\Checkout\Model\Session::CHECKOUT_STATE_BEGIN); } elseif (!$checkoutSessionQuote->getIsMultiShipping() && !in_array($action, array('login', 'register', 'success'))) { $this->_redirect('*/*/index'); $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); return parent::dispatch($request); } if (!in_array($action, array('login', 'register'))) { $customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session'); if (!$customerSession->authenticate($this, $this->_getHelper()->getMSLoginUrl())) { $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); } if (!$this->_objectManager->get('Magento\\Multishipping\\Helper\\Data')->isMultishippingCheckoutAvailable()) { $error = $this->_getCheckout()->getMinimumAmountError(); $this->messageManager->addError($error); $this->getResponse()->setRedirect($this->_getHelper()->getCartUrl()); $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); return parent::dispatch($request); } } if (!$this->_preDispatchValidateCustomer()) { return $this->getResponse(); } if ($this->_getCheckoutSession()->getCartWasUpdated(true) && !in_array($action, array('index', 'login', 'register', 'addresses', 'success'))) { $this->getResponse()->setRedirect($this->_getHelper()->getCartUrl()); $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); return parent::dispatch($request); } if ($action == 'success' && $this->_getCheckout()->getCheckoutSession()->getDisplaySuccess(true)) { return parent::dispatch($request); } $quote = $this->_getCheckout()->getQuote(); if (!$quote->hasItems() || $quote->getHasError() || $quote->isVirtual()) { $this->getResponse()->setRedirect($this->_getHelper()->getCartUrl()); $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); } return parent::dispatch($request); }