Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

How do you get Shopify order context in a post-purchase upsell extension?

bivers-eb
Shopify Partner
5 0 0

Hi all,

 

I've seen quite a few answers on this forum that refer to the Extension-UI React Hooks as being a convenient way to gain context regarding the originating order/customer/etc in the Extension-UI ecosystem, but that doesn't appear to be the correct path when building a post-purchase upsell extension. 

 

So my question is: what is the idiomatic way to get details about the originating Order (pre-upsell)?

 

I need to show upsells that are based off the items that were bought in the primary checkout (pre-upsell), and I'm fairly confused how to discover what those may be. I'm also not clear on how I can discover the customerId or any other relevant details for the originating order. 

Reply 1 (1)

bivers-eb
Shopify Partner
5 0 0

Update: I realized the inputData object is available in the upsell code as referenced in https://shopify.dev/docs/api/checkout-extensions/post-purchase/api#:~:text=Represents%20the%20initia...

 

This is helpful and gets me a lot farther, however instead of an OrderId, the API surfaces a referenceId. What is this ID and can it be correlated to a Shopify Order? I tried looking through the Shopify API references and didn't see anything specific.