本文整理汇总了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();
}