2
$this->checkoutSession->getLastRealOrder()
$this->checkoutSession->getLastRealOrderId()

returning null after payment gateway redirect.

Strange thing is that it is working some time and after it stops working.

What is the issue and how to get paid order on success page ?

0

Have you tried clearing the cache?

If it doesn't work, try following these steps:

  1. Pass Magento\Framework\App\Cache\TypeListInterface and Magento\Framework\App\Cache\Frontend\Pool to your file’s constructor as the following:

    public function __construct(
        Context $context,
        \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
        \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
    ) {
        parent::__construct($context);
        $this->_cacheTypeList = $cacheTypeList;
        $this->_cacheFrontendPool = $cacheFrontendPool;
    }
    
  2. Add these lines to the method where you want clear/ flush cache:

    $types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice');
    foreach ($types as $type) {
        $this->_cacheTypeList->cleanType($type);
    }
    foreach ($this->_cacheFrontendPool as $cacheFrontend) {
        $cacheFrontend->getBackend()->clean();
    

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.