Line level discounts in discount function

Hi,

Is there a way to get discounts applied on the cart in discount functions? I see all these values do not consider the line level discount already applied.

type CartLineCost {
“”"
The amount of the merchandise line.
“”"
amountPerQuantity: MoneyV2!

“”"
The compare at amount of the merchandise line.
“”"
compareAtAmountPerQuantity: MoneyV2

“”"
The cost of the merchandise line before line-level discounts.
“”"
subtotalAmount: MoneyV2!

“”"
The total cost of the merchandise line.
“”"
totalAmount: MoneyV2!
}

Nope. All discount functions run in parallel.

  • You can use order discount ‘conditions’ to apply order discount values ‘after product discounts’.
  • You can access totals/subtotals as expected (i.e after product and order discounts) in shipping discount functions.
  • You can use a discount allocator to have full knowledge of what discounts have a applied. Currently dev preview + only available for private custom apps for plus stores.
  • You can use the ‘fetch’ target to grab a list entered discount codes. This is only for enterprise custom apps (I believe).

Hope that helps

Thanks for this detailed answer

The discounts in this screenshot are product-level (aka cart line-level, I’m assuming that’s the same thing) discounts created with Discount Kit. They are both 10% with the second being clearly applying after the first. What do we konw about this priority logic?

Hey @Si_Hobbs - don’t know for sure, but from trial and error it appears:

  • percentage based is applied before fixedAmount based
  • The higher economic value is applied first.

@bkspace thanks and good to see you here :slight_smile:

@Gaurav_Agarwal Approach for Applying Multiple Discounts

If multiple discounts need to be applied cumulatively, the recommended approach is to create or modify a single Shopify Discount Function so that all required discount rules are evaluated and applied within that one function.

Reason: Shopify Functions execute independently and in parallel. Shopify does not pass the output of one Discount Function as the input to another. Instead, Shopify evaluates the discount results and applies the best applicable price/discount to the cart.

Therefore, if Discount Function 2 needs to consider the discount already calculated by Discount Function 1, both discount rules need to be handled within the same Discount Function.