22 private $persistenceSessionHelper;
29 private $persistenceDataHelper;
36 private $customerSession;
43 private $checkoutSession;
50 private $quoteManager;
57 private $cartRepository;
70 \
Magento\Persistent\Helper\Data $persistenceDataHelper,
75 \
Magento\Quote\Api\CartRepositoryInterface $cartRepository
77 $this->persistenceDataHelper = $persistenceDataHelper;
78 $this->persistenceSessionHelper = $persistenceSessionHelper;
79 $this->customerSession = $customerSession;
80 $this->checkoutSession = $checkoutSession;
81 $this->quoteManager = $quoteManager;
96 public function beforeSavePaymentInformationAndPlaceOrder(
100 \
Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
103 if ($this->persistenceSessionHelper->isPersistent()
104 && !$this->customerSession->isLoggedIn()
105 && $this->persistenceDataHelper->isShoppingCartPersist()
106 && $this->quoteManager->isPersistent()
108 $this->customerSession->setCustomerId(
null);
109 $this->customerSession->setCustomerGroupId(
null);
110 $this->quoteManager->convertCustomerCartToGuest();
112 $quote = $this->cartRepository->get($this->checkoutSession->getQuote()->getId());
114 $quote->getAddressesCollection()->walk(
'setEmail', [
'email' =>
$email]);
115 $this->cartRepository->save(
$quote);