0

When I placed order from checkout page with money order. User get redirected to empty cart page instead of success page.

I am using one step checkout in website.

0

Here is a temporary fix, it is not as per magento 2 standard. But as there is some existing issue with session in magento 2 and I have seen many of people facing same issue. I am sharing this temporary fix. Soon, I will update you with Correct answer.

Under vendor controller Magento\Checkout\Controller\Onepage open success.php file \vendor\magento\module-checkout\Controller\Onepage\Success.php

Just comment this line of code:

// return $this->resultRedirectFactory->create()->setPath('checkout/cart');

OR

you can create an observer for Success.php and custamize success controller.

  • Did you ever get an update? – tjjen Jan 8 '19 at 17:58
0

Are there any updates on this? I'm running across this now and seeing that this post is about 1-2 years old.. Is it still the appropriate fix, even if it's a temporary fix. It's unacceptable to be giving customers a confusing experience like this.. they are spending money, order is executing and they are getting a cart-empty page :(

0

We are too (Magento Commerce Cloud 2.2.5) -- but for any payment type, not just MO. Magento Support issued us a patch that addresses the PHP issue regarding secure sessions and referral checks...

... but that didn't fix the problem for us -- still getting random redirects to empty cart after the user presses Place Order (potential race condition).

MDVA-10441_EE_2.3.3_v3.composer

diff --git a/vendor/magento/module-checkout/Controller/Index/Index.php b/vendor/magento/module-checkout/Controller/Index/Index.php
index 0a5b7f190e3..9fe760d3fa7 100644
--- a/vendor/magento/module-checkout/Controller/Index/Index.php
+++ b/vendor/magento/module-checkout/Controller/Index/Index.php
@@ -32,11 +32,37 @@ class Index extends \Magento\Checkout\Controller\Onepage
             return $this->resultRedirectFactory->create()->setPath('checkout/cart');
         }

-        $this->_customerSession->regenerateId();
+        // generate session ID only if connection is unsecure according to issues in session_regenerate_id function.
+        // @see http://php.net/manual/en/function.session-regenerate-id.php
+        if (!$this->isSecureRequest()) {
+            $this->_customerSession->regenerateId();
+        }
         $this->_objectManager->get(\Magento\Checkout\Model\Session::class)->setCartWasUpdated(false);
         $this->getOnepage()->initCheckout();
         $resultPage = $this->resultPageFactory->create();
         $resultPage->getConfig()->getTitle()->set(__('Checkout'));
         return $resultPage;
     }
+
+    /**
+     * Checks if current request uses SSL and referer also is secure.
+     *
+     * @return bool
+     */
+    private function isSecureRequest(): bool
+    {
+        $secure = false;
+        $request = $this->getRequest();
+
+        if ($request->isSecure()) {
+            $secure = true;
+        }
+
+        if ($request->getHeader('referer')) {
+            $scheme = parse_url($request->getHeader('referer'), PHP_URL_SCHEME);
+            $secure = $scheme === 'https';
+        }
+
+        return $secure;
+    }
 }
diff --git a/vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js b/vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js
index f0679c657ab..0bb0a53ce0a 100644
--- a/vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js
+++ b/vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js
@@ -22,6 +22,7 @@ define([

                 return false;
             }
+            $(element).attr('disabled', true);
             location.href = config.checkoutUrl;
         });

diff --git a/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js b/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js
index 13a2b524e51..93a78e7d34c 100644
--- a/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js
+++ b/vendor/magento/module-checkout/view/frontend/web/js/sidebar.js
@@ -60,13 +60,15 @@ define([
             };
             events['click ' + this.options.button.checkout] = $.proxy(function () {
                 var cart = customerData.get('cart'),
-                    customer = customerData.get('customer');
+                    customer = customerData.get('customer'),
+                    element = $(this.options.button.checkout);

                 if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
                     // set URL for redirect on successful login/registration. It's postprocessed on backend.
                     $.cookie('login_redirect', this.options.url.checkout);

                     if (this.options.url.isRedirectRequired) {
+                        element.prop('disabled', true);
                         location.href = this.options.url.loginUrl;
                     } else {
                         authenticationPopup.showModal();
@@ -74,6 +76,7 @@ define([

                     return false;
                 }
+                element.prop('disabled', true);
                 location.href = this.options.url.checkout;
             }, this);

diff --git a/vendor/magento/module-customer/Model/Plugin/CustomerNotification.php b/vendor/magento/module-customer/Model/Plugin/CustomerNotification.php
index 3f73c8cdaee..2181e5b4578 100644
--- a/vendor/magento/module-customer/Model/Plugin/CustomerNotification.php
+++ b/vendor/magento/module-customer/Model/Plugin/CustomerNotification.php
@@ -85,11 +85,36 @@ class CustomerNotification
                 $customer = $this->customerRepository->getById($customerId);
                 $this->session->setCustomerData($customer);
                 $this->session->setCustomerGroupId($customer->getGroupId());
-                $this->session->regenerateId();
+                if (!$this->isSecureRequest($request)) {
+                    $this->session->regenerateId();
+                }
                 $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId);
             } catch (NoSuchEntityException $e) {
                 $this->logger->error($e);
             }
         }
     }
+
+    /**
+     * Checks if current request uses SSL and referer also is secure.
+     *
+     * @param RequestInterface $request
+     *
+     * @return bool
+     */
+    private function isSecureRequest(RequestInterface $request)
+    {
+        $secure = false;
+
+        if ($request->isSecure()) {
+            $secure = true;
+        }
+
+        if ($request->getHeader('referer')) {
+            $scheme = parse_url($request->getHeader('referer'), PHP_URL_SCHEME);
+            $secure = $scheme === 'https';
+        }
+
+        return $secure;
+    }
 }
  • Did you get this resolved? – tjjen Jan 8 '19 at 18:15

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.