Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Re: Post purchase extension: retrieve discount codes

Post purchase extension: retrieve discount codes

simon814
Visitor
3 0 0

Hello, 

 

I'm looking for a way to retrieve, in the post-purchase extension, the discount codes that the customer entered. According to the docs, I have access to the 'initialPurchase' but it does not seem to contain the discount codes that were used. Do you know a way to retrieve them? 

 

Thank you, 

Simon

Replies 4 (4)

gilg
Shopify Partner
31 6 6

You'll have to leverage the Shopify API for that. Both the order and checkout APIs have that information.

I make Checkout Promotions on the app store. Native pre & post purchase upsells - used by over 1,800 merchants.
simon814
Visitor
3 0 0

Thank you for your answer.

But I don't understand how I can retrieve the order or checkout from the post-purchase extension, as I don't have access to the order id or checkout token in the Checkout::PostPurchase::Render and Checkout::PostPurchase::ShouldRender extension points. 

I have access to the purchase reference id in inputData.initialPurchase but it seems useless to retrieve the corresponding order or checkout, isn't it? 

(I specify that I do not store the orders on my side)

 

Simon

simon814
Visitor
3 0 0

Hello, 

 

I still can't find a way to access the order id (or checkout token) in the post purchase extension, in order to get the discount codes. Does anyone have a solution? 

 

Thank you, 

Simon

GeniusWave
Shopify Partner
11 0 3

I'm dealing with the same issue, any solutions ?