Orders Creation Webhook problem

Solved
diegoalves
Excursionist
21 1 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
achieveapplabs
Shopify Partner
495 39 76

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

Use Approovly to create and track order approvals | Looking for more Shopify apps? achieveapplabs.com/#apps
0 Likes
CalD
Shopify Staff
Shopify Staff
130 15 19

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.

CalD | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

diegoalves
Excursionist
21 1 0

Thanks @CalD 

0 Likes