Fetch order and line-item level discounts used?

Fetch order and line-item level discounts used?

joeybab3
Shopify Partner
125 16 31

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.

Replies 4 (4)

Pogodan_
Shopify Partner
15 0 2

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

Pogodan | Partner Profile | Functions JSON config public/custom apps
joeybab3
Shopify Partner
125 16 31

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. 

Pogodan_
Shopify Partner
15 0 2

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.

Pogodan | Partner Profile | Functions JSON config public/custom apps
tobebuilds
Shopify Partner
420 28 110

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

Founder, Regios Discounts app (4.9 stars)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer