0

I want to move an inactive quote to the checkout page.

A customer searches for products and adds them in the cart but doesn't want to checkout on that day.

Now on next day he wants to order some products which are not present in the current cart. He also wants to keep all the current product in the cart.

My solution to this is, the customer will make the current cart(quote) to inactive (By clicking some button on the cart page). This quote will be visible in my account section.

I need an ability to move this inactive cart to an active cart. That is when the customer wants to continue to do checkout of this quote.

6
1
+50

Assume the

$activeQuoteId is the id of current activeQuote

$inActiveQuoteId is the id of current inactiveQuote

And 2 quotes must belong to customer,

You should active which quote do you want for customer, then set to current checkout session.

        /** @var $activeQuote \Magento\Quote\Model\Quote */
        $activeQuote = $this->quoteRepository->get($activeQuoteId);
        $activeQuote->setIsActive(0);
        $this->quoteRepository->save($activeQuote);

        /** @var $inActiveQuote \Magento\Quote\Model\Quote */
        $inActiveQuote = $this->quoteRepository->get($inActiveQuoteId);
        $inActiveQuote->setIsActive(1)->setReservedOrderId(null);
        $this->quoteRepository->save($inActiveQuote);

        /** @var $session \Magento\Checkout\Model\Session */
        $session->replaceQuote($inActiveQuote);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.