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.

Orders Creation Webhook problem

Solved

Orders Creation Webhook problem

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?

Accepted Solution (1)

CalD
Shopify Staff
140 22 36

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

View solution in original post

Replies 3 (3)

Not applicable

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

CalD
Shopify Staff
140 22 36

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