How does discountApplications & discountAllocations behave with multiple discount codes in Discount Functions?

Hi all, I’m creating an discount function and I’m confused about the cart.discountApplications|line.discountAllocations field.

My assumption from the docs is that these fields should list discounts that have already been applied to the cart (or line items), so I expected to see previously‑applied discounts there.

My test case:

  • Code A = 10% off
  • Code B = 20% off
  • Combination is enabled, and in the cart/checkout UI I can clearly see both discounts applied.

In my Discount Function input for the run triggered by Code B:

  • triggeringDiscountCode is "B"
  • enteredDiscountCodes contains both "A" and "B"
  • But cart.discountApplications is always just []

So even though a previous discount is visibly applied, cart.discountApplications is empty.

Is this expected behavior with the unified Discount Function API? Or am I misunderstanding how discountApplications is supposed to work here?

Hi @webx47

From digging into this, it does appear that this is expected behaviour, from our docs:

“All discount functions run concurrently, and have no knowledge of each other.”

With two function-based discount codes (A and B), it’s expected that:

  • enteredDiscountCodes shows both "A" and "B";
  • triggeringDiscountCode is "B" in B’s run;
  • cart.discountApplications and line discountAllocations remain empty (for other functions’ discounts) within that run.

If your goal is something like:

  • “If code A is already applied, adjust B’s behavior”, or
  • “Cap total discount across all active codes”,

then with today’s Discount Function API you cannot derive that from cart.discountApplications.

Hi @Liam-Shopify, any idea than what’s the use of this discountAllocation/Application field?

Hi @Liam-Shopify! Just bumping this thread since i stepped in the same problem. I’m curious to understand the possible uses of discountApplications since it doesn’t appear to detect app-based or native discounts.

image