Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
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.
Following... thanks.
(y) Agreed!
So it's 2021! Any update on this? I still don't see price rules or discount webhooks in the REST Admin API docs.
2022 any update on this, any chance?
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.
Is this feature implemented?
This is a much needed feature.
It would be very helpful feature and clearly many developer needs it. Any update would be helpful!!
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