Hi there all,
Probably a simple question, but I'm having a hard time finding documentation around this.
I have an app that adds functionality to the order status page that's shown to the customer immediately after checkout.
There's a special display scope for script tags only running on this particular page called "ORDER_STATUS": https://shopify.dev/docs/admin-api/graphql/reference/online-store/scripttagdisplayscope
This is a great way to extend the post-checkout experience without requiring the merchant to do any liquid code changes whatsoever. Extremely user friendly.
However, loading the script isn't the problem - it's actually accessing the order data that's an issue.
I've found this hack where you can access the order data via the `window.Shopify` object by calling `window.Shopify.order.id`. My API will load the order ID and populate the data as necessary. However, I'm discovering the order data doesn't always load, the `window.Shopify.order.id` attribute is null or undefined.
Perhaps I'm running into a race condition and need to wait to call my own API after this variable is available in the browser window. I feel like this solution is a hack - is there another way to access the current order from the order status page?