- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cart Items are deleted after fail checkout magento2.2.1
Summary of the issue
When I try to place an order with all the required information filled in and choose the mode of payment as PayUmoney payment Gateway then post click of Place order button, it redirects me to Payumoney popup. If I cancel the transaction on reaching this stage then in Magento Admin Panel it shows in an ordered list with the order payment status as"pending payment" which should not be the case. Instead, it should show canceled status without affecting the inventory.
precondition
Magento 2.2.1
PHP 7.0
SQL 5.7
Steps to reproduce
- Add item to cart
- Proceed to checkout
- Checkout using Credit/Debit card.
- Refresh/go back page, cancel payment, failed payment
Expected results
- if refreshed page/go back - item should still be in still in the cart
- cancel/failed payment - give options to try again or even choose a different payment method.
Actual result
- clears item and redirects to an empty page (nothing is in your shopping cart)
- URL is still cart/checkout
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Cart Items are deleted after fail checkout magento2.2.1
Below is the solutions to "prevent magento 2.3.5 version from emptying cart after payment cancellation"
Please override Failure.php and change public function as below
public function execute() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $_checkoutSession = $objectManager->create('\Magento\Checkout\Model\Session'); $_quoteFactory = $objectManager->create('\Magento\Quote\Model\QuoteFactory'); $order = $_checkoutSession->getLastRealOrder(); $quote = $_quoteFactory->create()->loadByIdWithoutStore($order->getQuoteId()); if ($quote->getId()) { $quote->setIsActive(1)->setReservedOrderId(null)->save(); $_checkoutSession->replaceQuote($quote); $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('checkout/cart'); //$this->messageManager->addWarningMessage('Payment Failed.'); return $resultRedirect; } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Cart Items are deleted after fail checkout magento2.2.1
Hello
check the below reference to get an idea,
https://magecomp.com/blog/prevent-magento-from-emptying-cart-after-payment-cancellation/
http://ka.lpe.sh/2011/12/31/magento-getting-back-shopping-cart-items-after-order-fails/