22

I have an issue in Magento 2 success page, its showing blank after successfully placed order. I am trying to debug it but the issue is when trying to refresh the success page after changing the code it a clear current session and redirecting to the home page. I want to stop redirecting the success page and stay the same page when the refresh page.

Have anybody Idea in Magento 2? Please let me know if anyone already does this?

5 Answers 5

79

You can stop checkout success page redirection after refresh page, check below code

vendor/magento/module-checkout/Controller/Onepage/Success.php

Comment Out Line No : 26 (in Magento 2.4)

//$session->clearQuote();

Now you can debug checkout success page.

3
  • Yes,Ok this is working.
    – akgola
    Jan 29, 2018 at 7:32
  • 5
    Line 26 (as of Magento 2.3.1) May 1, 2019 at 16:03
  • 2
    It's working on Magento 2.4.5-p1 version. Apr 20 at 7:26
8

Kindly open Magento\Checkout\Controller\Onepage\Success.php and comment below line

$session->clearQuote(); 

for temporary purpose.

3

You can also install the Magepal module which works perfectly without any code modification. Make sure to install it as a dev requirements:

composer require --dev magepal/magento2-preview-checkout-success-page
2

You can stop checkout success page redirection after refresh page, check below code

vendor/magento/module-checkout/Controller/Onepage/Success.php

Comment Out Line No : 22 And in Magento 2.3... Line No : 26

//$session->clearQuote();

Ex :-

public function execute()
    {
        $session = $this->getOnepage()->getCheckout();
        if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
            return $this->resultRedirectFactory->create()->setPath('checkout/cart');
        }

        // $session->clearQuote();            ***** COMMENT THIS LINE *****

        //@todo: Refactor it to match CQRS
        $resultPage = $this->resultPageFactory->create();
        $this->_eventManager->dispatch(
            'checkout_onepage_controller_success_action',
            [
                'order_ids' => [$session->getLastOrderId()],
                'order' => $session->getLastRealOrder()
            ]
        );
        return $resultPage;
    }

Now you can debug checkout success page.

0

If some have still issue with it. I have recorded video. You can follow up this video also.

https://www.youtube.com/watch?v=xMvR_PmDABg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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