1

I am using Magento 2.2.4, my problem is:
I am using 2 events one page checkout success and sales order place after. In my controller I am getting order id from customer session using $orderIncrementId = $this->checkoutSession->getLastRealOrderId();
Now when the flow goes with one page checkout everything works fine. But when I select ship to multiple addresses, event I used to get order id is sales order place after. The Id is random id from previous order. Also no payment details present in order collection

  • Have you unset your session in sales order place after event ? – Mukesh Prajapati Oct 1 '18 at 5:20
  • No, is it required in the case of customer checkout session, because for normal flow it is working fine, only when ship to multiple address then order id is random previous order id – Surjan Raghuwanshi Oct 1 '18 at 5:23
0

I think we can use the observer in this case:

https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/GoogleAnalytics/etc/frontend/events.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_onepage_controller_success_action">
        <observer name="googleanalytics_order_success" instance="Magento\GoogleAnalytics\Observer\SetGoogleAnalyticsOnOrderSuccessPageViewObserver" />
    </event>
    <event name="multishipping_checkout_controller_success_action">
        <observer name="googleanalytics_order_success" instance="Magento\GoogleAnalytics\Observer\SetGoogleAnalyticsOnOrderSuccessPageViewObserver" />
    </event>
</config>

Need to take a look at the Google Analytics for more details.

  • I'm already using observer – Surjan Raghuwanshi Oct 1 '18 at 4:48
  • It should work. Could you show me your what you're trying with obsevers? – Khoa TruongDinh Oct 1 '18 at 4:52
  • I used events.xml file similar to yours, I handled that event in observer and from observer calling my controller and using checkout session to get order Id – Surjan Raghuwanshi Oct 1 '18 at 5:01
  • In the case of ship to multiple the order id is random previous order id. If I go with normal flow that is one page success event, everything working fine – Surjan Raghuwanshi Oct 1 '18 at 5:01

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.