Question

In mage1 there was $session->clear() but cannot find where it is done in magento2?

I thought it was $this->checkoutSession->clearQuote()->clearStorage(); in

vendor/magento/module-checkout/Observer/UnsetAllObserver.php

but it's not.

Was it helpful?

Solution

Check following file and code.


# Magento/Checkout/Controller/Onepage/Success.php

$session->clearQuote();

OTHER TIPS

Another quicker way to do this is to edit the isValid() method in

app/code/Magento/Checkout/Model/Session/SuccessValidator.php

and set an existing order id, then navigate to your success page (site.com/checkout/onepage/success)

See https://github.com/magepal/magento2-preview-checkout-success-page

$orderId = 123;
$incrementId = '000001'

$this->checkoutSession
     ->setLastOrderId($orderId)
     ->setLastRealOrderId($incrementId);

     return true;
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top