User experience, by no doubt, is important for a successful E-commerce store. Right from the visit to the site, through the conversion step and even after the purchase, the best user experience must be offered to the customers.
It may happen that when a customer is redirected to 3rd party payment site, the payment is failed due to some technical error or he decides to postpone the payment process for future, he clicks the back button and gets redirected back to the Magento store with an empty cart. If he wants to place the order again, he has to add products to cart again and proceed from scratch. It hinders the shopping experience.
Such a situation forces the user to again fill the cart which is tedious. He may decide to abandon the shopping. To avoid it, make sure to restore Magento Quote after payment refusal. Here, I’ll show how to improve the user experience by preventing Magento to empty the cart in the case of failed payments.
Implement the below code to prevent Magento to empty cart after failed payments!
Method to Restore Magento Quote After Payment Refusal:
in YourIcancelAction() Or failureAction();
Add below code to restore the previous cart:
if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) { if ($lastQuoteId = Mage::getSingleton('checkout/session')->getLastQuoteId()) { $quote = Mage::getModel('sales/quote')->load($lastQuoteId); $quote->setIsActive(true)->save(); } }
With this method, your store customers will no longer have to come back to an empty cart!
Thank you