Magento 1.8 – Fix Mage::getSingleton(‘checkout/session’)->getLastRealOrderId() Issue

magento-1.8

I'm using paypal standard as a payment system and want to get the last order id and for that I'm using age::getSingleton('checkout/session') ->getLastRealOrderId();

But this is not giving me the last placed order ID., I've checked in the modal app/code/local/Mage/Paypal/Model/ipn.php in method _registerPaymentCapture I've tried saving the order into a session so that I can get it on success page…but that is also not working.

Any help is much appreciated.

Best Answer

ravi,there place where this session is place

First , this session variable is set at Mage_Checkout_Model_Type_Onepage on function saveOrder here thus session variable is set for first time before redirecting to paygate way.

For Paypal,if customer is cancel this payment at paypal site and comes to magento paypal cancel url then on cancelAction this session variable is destroyed.So,you do not get realorderid .beacuse using ->unsLastOrderId() destroy realorderid .

Check at

Mage_Paypal_Controller_Express_Abstract
Mage_Paypal_PayflowadvancedController
Mage_Paypal_PayflowController
Mage_Paypal_StandardController