Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

bivers-eb
Shopify Partner
5 0 1

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 1

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.