Thanks for the quick reply Josh,
Sure! I can provide an example use case. My actual use case is a little ‘out there’ from what I can tell so I’ll try to use an example application that is a bit more to the point.
Let’s say we want to make an app that tracks all the cart updates that shoppers make and reports back to the seller what PriceRules could have been triggered at each stage of their carts’ life cycles on the Shopify Admin Panel.
This app could then ‘dry run’ price rules to see how often they’d be triggered, or how close they are to being triggered, before making them live on a shop. The reported information from the app could then be used for many things including increasing the amount of profit that up sells and cross-sells triggered by PriceRules create and when those discounts should be offered to get users to change their cart to something more favourable.
To make such an app with Shopify’s current solutions I think you would have to:
-
pull in all of the seller’s PriceRules from Shopify using the admin API or GraphQl
-
receive webhook updates for the cart creation and updates
-
re-create Shopify’s price rule checking code to loop through all of the price rules to see if any of them are applicable to the cart’s current state. Or you’d need to create your own price rule system which isn’t really where the app’s value is.
Instead it would be great if the app could focus on it’s core value, it’s reporting, and let shopify run the price rule checking like it already does for discount codes applied at check out.
In this case, the app would be written like this:
-
receive webhook updates for cart creation and updates.
-
send the cart’s state (or for other apps, the order’s state) to a shopify endpoint that responds with price rules that are matched, and how they stack.
-
Store the responses in a database and write the reporting code.
Essentially, I’m trying to not re-write the code that shopify uses to compare price rules with an order or cart to see if they are valid.