Ability to get order_number via javascript on Order Status page

Highlighted
Shopify Partner
53 1 11

Currently there does not appear to be a way to get the order_number via javascript on the order status page.

 

You can get many other attributes for the order via Shopify.checkout.order_id, Shopify.checkout.billing_address, Shopify.checkout.discount, Shopify.checkout.email ect.

 

We really need to be able to get the order_number.  Would it be possible to add Shopify.checkout.order_number to be available here?

 

Thank you

0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

Hey @Corknine,

 

I just took a look as well, but wasn't able to find a way to get this on the order status page. Would you mind providing some context as to how you plan to use this data? I can definitely submit your feedback to our developers if this is something they feel would benefit the platform. While there's no guarantee for if/when that will be implemented, our developers always consider user feedback when implementing new features or making changes to the platform, so this is the best way to pass that feedback along.

 

In the meantime, one option is to grab the Shopify.checkout.order_id value, and use that to make a call to the orders API to grab the order.name field. For example, a GET to myshopify.com/admin/orders/1400717574166.json?fields=name will return:

 

{ 
"order": { "name": "#2017" }
}

You can also consider parsing out the value from HTML, though this isn't 100% reliable as there's no guarantee that the HTML won't change: 

 

20-01-z6c9f-0reqf

 

A hybrid of these 2 options could also work, if you wanted to parse out the value from HTML, and then run a job every so often to call the orders API for anything that might be missing.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

Hi again @Corknine,

 

Just realized I may have been overthinking this one. Although the order_name isn't directly available on the order status page, you can use the order liquid variable for order_name in your script, and this will populate the value before the script is rendered. The variable to use is {{checkout.order.name}}. Let me know if that works for you!

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
53 1 11

Hello JB,

Using the value in liquid won't work as we are trying to get the order number directly via an injected script_tag so the merchant doesn't need to add any code.

 

We are able to get the id, however we are using this to create a specific link to the order and want to verify a match between two parameter(so you can't randomly find the page by just guessing an ID, the id and order_number must match).  We cannot use the api to grab the name as this would add an extra API call and essentially half the number of calls we can make.  I'm sure there are many other ways having the order_number available on the Shopify.checkout object would help developers to use the script tag to add order status page content.  Please consider making this available via JS as it would greatly simplify the ability to add integrations that did not require the merchants to add custom code. 

We used to use the email for this validation matching, however with CCPA we want to remove emails from the url fields so the merchants can be compliant with CCPA and we need to match on order_number/id instead of email/id

0 Likes