Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I have been reading all the documentation searching for anything that would allow me to pull what discounts were used on an order. Am I correct in seeing that there is currently no way to pull the discounts on an order? I see discountNode in the top level input but there are only metafields on that object.
The goal here is to make sure that only one discount is allowed per product, whether that is order level or line item level.
You can set the `combinesWith` property of your discounts not to combine, and Shopify should select the best discount of the ones available to allocate to the order. Discount functions run in parallel so one can't see what the other is doing. If you have a more complex use case, check Discounts Allocator Function API https://shopify.dev/docs/api/functions/reference/discounts-allocator
We want the discounts to combine though, just not on a per line item basis.
i.e. User uses a 10% order level discount and a 25% one item discount, they would get 25% off the line item relevant to the code and 10% off the rest of their cart but not 35% off the line item that technically both discounts could apply to.
I think you would need to either look into the discount allocator function API, or integrate the necessary logic into your order/product discount functions so one function would adjust its behavior based on knowing the input would otherwise result in "stacked" discounts.
Hi Joeybab3,
Two product discounts will never be applied to the same line item simultaneously (unless you're using a custom Discounts Allocator that supports this logic).
I recommend reading this helpdesk article, which explains the rules for combining discounts:
https://help.shopify.com/en/manual/discounts/combining-discounts/discount-combinations
In the scenario you outlined, I would recommend against making the 10% discount an order discount. Instead, make it a 10% product discount for all products in the cart. When a specific product gets a 25% discount, the 25% will override the 10% for that specific line item. The other line items will have the 10% applied.
Best,
Tobe