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: Webhook/API requests for PriceRules/Discounts

Webhook/API requests for PriceRules/Discounts

DiscountNinja
Shopify Partner
104 0 67

Request 1: ability to lookup PriceRule/Discount via discount code

To find the PriceRule that matches a given discount code (string) the API (https://help.shopify.com/api/reference/pricerule#show) requires a developer to:

- Get all PriceRules (per group of 250)

- Get each PriceRule and either inspect the Title (assuming it is the same as the DiscountCode) or get the DiscountCodes associated with it (https://help.shopify.com/api/reference/discountcode#show) to see the details and check if the code matches

For merchants that have large quantities of PriceRules the above system is very impractical. It is easy to hit the throttling limits. 

It would therefore be interesting to have an endpoint that allows lookup of a PriceRule (or potentially a list of PriceRules?) based on the discount code.

Request 2: webhooks

Also, in the development of our apps, we found the following webhooks would be very useful: PriceRule/create PriceRule/update and PriceRule/delete. Unfortunatley the documentation does not list any webhooks related to Price Rules or Discounts (https://help.shopify.com/api/reference/webhook).

Why? To allow us to keep a cache of discount codes/price rules in sync.

Why do you need a cache? Because calls to the PriceRules / Discount API are too expensive for some scenarios and because the amount of calls required can exceed the throttling limit.

Without webhooks we need to resort to polling the PriceRules API for changes. This means our cache is always out of date (and also may contain codes that actually do not exist anymore).

Am I missing something? Looking forward to hear about your perspective on this.

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
Replies 9 (9)

rmanke
Shopify Partner
183 0 59

Following... thanks.

Shopify Partner, software developer and designer.

Talha
Tourist
11 0 7

(y) Agreed!

devHam
Tourist
8 0 3

So it's 2021! Any update on this? I still don't see price rules or discount webhooks in the REST Admin API docs.

amanuelZelealem
Visitor
1 0 2

2022 any update on this, any chance? 

ilevy
Visitor
1 0 0

100% agreed, we need this feature as well.
Would also be very useful to have a "discount analysis" endpoint, wherein you submit customer.id + cart.id + current page, and you get all relevant discounts / price rules.

senlinwei321
Shopify Partner
1 0 1

Is this feature implemented?

vivek-kumar
Shopify Partner
1 0 1

This is a much needed feature.

abhishektaparia
Shopify Partner
9 0 6

It would be very helpful feature and clearly many developer needs it. Any update would be helpful!!

ShopifyDevSup
Shopify Staff
1453 238 519

Hi @abhishektaparia 👋

 

Instead of PriceRules, I'd recommend using the types and queries detailed in this Getting started with discounts guide. These will replace the GraphQL `PriceRule` object and REST Admin `PriceRule` and `DiscountCode` resources.

 

Hope that helps!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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