70 public function setGuest($checkQuote =
false)
73 $quote = $this->checkoutSession->getQuote();
75 if ($checkQuote && !$this->persistentData->isShoppingCartPersist() && !
$quote->getIsPersistent()) {
76 $this->checkoutSession->clearQuote()->clearStorage();
80 $quote->getPaymentsCollection()->walk(
'delete');
81 $quote->getAddressesCollection()->walk(
'delete');
82 $this->_setQuotePersistent =
false;
85 ->setCustomerEmail(
null)
86 ->setCustomerFirstname(
null)
87 ->setCustomerLastname(
null)
88 ->setCustomerGroupId(\
Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID)
89 ->setIsPersistent(
false)
90 ->removeAllAddresses();
92 $quote->getShippingAddress();
93 $quote->getBillingAddress();
95 $this->quoteRepository->save(
$quote);
98 $this->persistentSession->getSession()->removePersistentCookie();
109 public function convertCustomerCartToGuest()
112 $quote = $this->quoteRepository->get($this->checkoutSession->getQuoteId());
114 $this->_setQuotePersistent =
false;
116 ->setCustomerId(
null)
117 ->setCustomerEmail(
null)
118 ->setCustomerFirstname(
null)
119 ->setCustomerLastname(
null)
120 ->setCustomerGroupId(\
Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID)
121 ->setIsPersistent(
false);
122 $quote->getAddressesCollection()->walk(
'setCustomerAddressId', [
'customerAddressId' =>
null]);
123 $quote->getAddressesCollection()->walk(
'setCustomerId', [
'customerId' =>
null]);
124 $quote->getAddressesCollection()->walk(
'setEmail', [
'email' =>
null]);
126 $this->persistentSession->getSession()->removePersistentCookie();
127 $this->quoteRepository->save(
$quote);
138 $quote = $this->checkoutSession->setLoadInactive()->getQuote();
140 $this->checkoutSession->setCustomerData(
null)->clearQuote()->clearStorage();
143 ->setIsPersistent(
false)
144 ->setCustomerId(
null)
145 ->setCustomerGroupId(\
Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
__construct(\Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Helper\Data $persistentData, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository)