Is there a way to fetch order shipping information in post-purchase checkout extensions?

Is there a way to fetch order shipping information in post-purchase checkout extensions?

Danh11
Shopify Partner
87 2 39

Ideally I would like to fetch the amount the customer has paid for shipping, and apply it as a discount to the post-purchase product offer if the customer accepts the offer and the total price exceeded the free shipping threshold.

As far as I can tell, it's not available. My workaround was to fetch it via the admin API, but I'm not sure if that's possible without knowing the order ID which doesn't seem to be available.

Is there a way to achieve this? 🙂

Replies 2 (2)

Turbofan1178
Shopify Partner
57 4 10

Have you tried using the `useShippingAddress` hook?

 

Can be found here: https://shopify.dev/docs/api/checkout-ui-extensions/2023-10/apis/addresses

Founder, WC: Invite To WhatsApp Channel
- Invite customers to join your WhatsApp channel with a single click
- Boost outreach message open rates
- Grow sales with direct outreach on WhatsApp channels
Danh11
Shopify Partner
87 2 39

I'm not sure your solution caters to my issue? 🙂

I found a workaround using the shopify web pixel checkout_started event. This event gives you a checkout token which also aligns with an ID that you receive in the post-purchase event. This can then be used to cross-match more information that the checkout_started web pixel event gives you. You just have to store some data from the checkout_started event to the user in your database, and then fetch that data from the post-purchase extension side of the app. It would probably require some intermittent polling of the database to retrieve it as there will be two seperate operations running at once, but it should work ok.

 

I haven't actually done it yet though but it seems reasonable enough.