本文整理匯總了PHP中Magento\Checkout\Model\Session::clearQuote方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::clearQuote方法的具體用法?PHP Session::clearQuote怎麽用?PHP Session::clearQuote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Checkout\Model\Session
的用法示例。
在下文中一共展示了Session::clearQuote方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setGuest
/**
* Make quote to be guest
*
* @param bool $checkQuote Check quote to be persistent (not stolen)
* @return void
*/
public function setGuest($checkQuote = false)
{
/** @var $quote \Magento\Sales\Model\Quote */
$quote = $this->checkoutSession->getQuote();
if ($quote && $quote->getId()) {
if ($checkQuote && !$this->persistentData->isShoppingCartPersist() && !$quote->getIsPersistent()) {
$this->checkoutSession->clearQuote()->clearStorage();
return;
}
$quote->getPaymentsCollection()->walk('delete');
$quote->getAddressesCollection()->walk('delete');
$this->_setQuotePersistent = false;
$quote->setIsActive(true)->setCustomerId(null)->setCustomerEmail(null)->setCustomerFirstname(null)->setCustomerLastname(null)->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID)->setIsPersistent(false)->removeAllAddresses();
//Create guest addresses
$quote->getShippingAddress();
$quote->getBillingAddress();
$quote->collectTotals()->save();
}
$this->persistentSession->getSession()->removePersistentCookie();
}
示例2: execute
/**
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @codeCoverageIgnore
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$this->checkoutSession->clearQuote()->clearStorage();
}