/** * Get checkout method * * @param Quote $quote * @return string */ private function getCheckoutMethod(Quote $quote) { if ($this->customerSession->isLoggedIn()) { return Onepage::METHOD_CUSTOMER; } if (!$quote->getCheckoutMethod()) { if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Onepage::METHOD_GUEST); } else { $quote->setCheckoutMethod(Onepage::METHOD_REGISTER); } } return $quote->getCheckoutMethod(); }
public function testIsAllowedGuestCheckoutWithoutStore() { $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false); $store = null; $quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(1)); $this->_scopeConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(true)); $this->assertTrue($this->_helper->isAllowedGuestCheckout($quoteMock, $store)); }
/** * Validate quote state to be integrated with one page checkout process * * @return void * @throws \Magento\Framework\Exception\LocalizedException */ protected function validate() { $quote = $this->getQuote(); if ($quote->isMultipleShippingAddresses()) { throw new \Magento\Framework\Exception\LocalizedException(__('There are more than one shipping addresses.')); } if ($quote->getCheckoutMethod() == self::METHOD_GUEST && !$this->_helper->isAllowedGuestCheckout($quote)) { throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, guest checkout is not available.')); } }
/** * Don't display the shortcut button if customer is not logged in and guest mode is not allowed * * @return bool */ public function skipShortcutForGuest() { if ($this->customerSession->isLoggedIn()) { return false; } if ($this->checkoutData->isAllowedGuestCheckout($this->checkoutSession->getQuote())) { return false; } return true; }
/** * Get checkout method * * @return string */ public function getCheckoutMethod() { if ($this->_cart->getCustomerSession()->isLoggedIn()) { return \Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER; } if (!$this->_cart->getQuote()->getCheckoutMethod()) { if ($this->_checkoutData->isAllowedGuestCheckout($this->_cart->getQuote())) { $this->_cart->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST); } else { $this->_cart->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); } } return $this->_cart->getQuote()->getCheckoutMethod(); }
/** * Check if guest checkout is allowed * * @return bool */ public function isGuestCheckoutAllowed() { return $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote()); }
/** * Check if guests checkout is allowed * * @return bool */ public function isAllowedGuestCheckout() { return $this->_checkoutData->isAllowedGuestCheckout($this->getQuote()); }