Programatically getting order information in javascript on the order status page

Corknine
Shopify Partner
61 1 17

Hello,

We are using the addContentBox() javascript method on the order confirmation page to dynamically add content to the order status page without requiring the merchant to add code to store.

This works great in most cases and makes things much easier for the merchant.  We are currently fetching the details of the order via javascript to use to add the dynamic content be fetching them from the Shopify.checkout variable.  This works great, except when the order does not have a checkout(draft order ect).

To make things more reliable it would be great if some of the order details were available via javascript so they could be used to add the correct dynamic content.  The ones we would need most would be the order_id, order_number, and order_email.  We currently get some of these off the the Shopify.checkout variable, however that is not always available.

This is a great method for apps to add content the the order status page without requiring the merchant to add custom code, however in order for apps to be able to use this correctly we need to be able to get some information on which order is being viewed via Javascript(not liquid).  Please consider exposing the order information in JS for this use case.

0 Likes
_JB
Shopify Staff
Shopify Staff
817 96 177

Hey @Corknine,

Can you provide some checkout_ids where this information wasn't available from the Shopify.checkout object?

As far as I know, the order information you're looking for should almost always be available through that object. The only time I expect the information to not be available is if order processing was delayed, which happens very rarely.

For context on delayed order processing: In normal circumstances, Shopify receives a successful payment response from the gateway, generates the order in our database, and then redirects the customer to the thank_you page which contains the order number. When order processing is delayed, this means Shopify needs more time to generate the order after receiving confirmation of payment. Note that this happens very rarely, but can occur due to increased server load or network issues. When order processing is delayed, the customer is redirected to the thank_you page before the order is generated (rather than leaving them staring at a spinner on the processing page). In this case since the order number hasn't been generated yet, the page shows a message advising it will come in an e-mail. This is the only scenario I'm aware of where the order_id won't be available in the Shopify.checkout object, and it shouldn't happen often enough for you to notice. If you send along those checkout_ids I can dig deeper to see what's happening.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Corknine
Shopify Partner
61 1 17

Hi @_JB,

Thanks for the response.  An example Order ID that has this issue is 2480764026993(note this is an Order ID and not a checkout id as there is no checkout).  This order has not Shopify.checkout object and Shopify.Checkout.token is null as well.  I believe this affects any order that is created as a Draft order by the merchant, however on these orders(and all orders) apps still need to be able to get information about the order itself.

I also notice that on all orders(even those with a Shopify.checkout) there is no way to get the order number via JS.  Ideally apps should be able to get the order number as well as the id, email and other attributes.  Is it possible to make the order_number and other order attributes available via javascript?

0 Likes
_JB
Shopify Staff
Shopify Staff
817 96 177

Hey @Corknine,

It looks like that order actually originated from an import, not a draft. Since imported orders don't have a checkout associated, it's expected in this case for the Shopify.checkout object to be unavailable. I'll submit feedback to our product teams to see if it's possible to add any order data to this page as a JS object. I can't make any promises as to if/when this will be implemented, but I'll post back here if there are any updates to share.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Corknine
Shopify Partner
61 1 17

Thanks @_JB ,

I really appreciate it.  It would be very helpful if there was a reliable way to get order details via JS for all orders on the order status page.

Thank You,

-Andrew

0 Likes