Orders Creation Webhook problem

Solved
Highlighted
New Member
15 0 0

Hello,

I created an orders create webhook to check if an orders has an specific discount code applied.

I can get that with webhook, but to check this I need the discount code title, which is not coming in the webhook.

Can I get the discount code title in other way?

0 Likes
Highlighted
Shopify Partner
349 25 52

Yes you can GET discounts.json to see if that discount code has been used. 

Custom Apps and Themes Support | Email us: hello@achieveapplabs.com | Follow us on Twitter @achieveapplabs | New Monthly Support by Achieve Applabs www.achieveapplabs.com
0 Likes
Highlighted
Shopify Staff
Shopify Staff
59 7 10

This is an accepted solution.

Hi @diegoalves,

The discount code sent in the webhook does indeed contain the discount codes applied:

       "discount_applications": [{
		...
	}],
	"discount_codes": [{
		"code": "SUMMERSALE10OFF",
		"amount": "9.70",
		"type": "percentage"
	}],
	"note_attributes": [...],

You can GET /admin/api/2020-07/price_rules.json which will contain the "title" key? And may also need to GET /admin/api/2020-07/price_rules/{price_rule_id}/discount_codes.json for the codes under that price rule, if the "title" of the PriceRule is different from the "code" of the DiscountCode.

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
New Member
15 0 0

Thanks @CalD 

0 Likes