- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018
03:12 PM
10-15-2018
03:12 PM
Magento 2.x.x - cart/checkout item clears after failed payment
Hi there!
How do I prevent items in my cart to clear after a failed payment? It seems this problem only occurs when I use Paypal's Pro Hosted solution.
precondition
Magento 2.2.2
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
Labels:
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019
05:52 AM
08-29-2019
05:52 AM
Re: Magento 2.x.x - cart/checkout item clears after failed payment
Hello @tim_muangkeo
Did you follow this blog?
http://magecomp.com/blog/prevent-magento-from-emptying-cart-after-payment-cancellation/ |
Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2020
02:08 PM
07-02-2020
02:08 PM
Re: Magento 2.x.x - cart/checkout item clears after failed payment
Below is the solution for magento 2.3.5
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
08-02-2020
11:52 PM
08-02-2020
11:52 PM
Re: Magento 2.x.x - cart/checkout item clears after failed payment
Please mention the file path for Failure.php.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2021
05:10 AM
05-16-2021
05:10 AM
Re: Magento 2.x.x - cart/checkout item clears after failed payment
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/