Hi team,
When using Shopify Functions to apply multiple product discounts with the same discount code/message, Shopify renders multiple discount lines in the order summary (e.g., order confirmation), even though the discount logic is identical.
We attempted to merge the discount targets to work around this, but it leads to incorrect behavior when combining multiple product-level discounts—the total discount amount is calculated incorrectly.
Steps to reproduce
- Use Shopify Functions to apply product discounts with the following example structure:
Case 1 – Separate discounts with same message (renders as 2 lines):
"output": {
"discountApplicationStrategy": "ALL",
"discounts": [
{
"message": "SYMB798EGY5R",
"targets": [{ "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 1 } }],
"value": { "fixedAmount": { "amount": "1.5", "appliesToEachItem": false } }
},
{
"message": "SYMB798EGY5R",
"targets": [{ "cartLine": { "id": "gid://shopify/CartLine/0", "quantity": 1 } }],
"value": { "fixedAmount": { "amount": "1.5", "appliesToEachItem": false } }
}
]
}
Result: Order summary displays two lines with the same discount code.
Case 2 – Merged targets to one discount:
"output": {
"discountApplicationStrategy": "ALL",
"discounts": [
{
"message": "SYMB798EGY5R",
"targets": [
{ "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 1 } },
{ "cartLine": { "id": "gid://shopify/CartLine/0", "quantity": 1 } }
],
"value": { "fixedAmount": { "amount": "3", "appliesToEachItem": false } }
}
]
}
Then apply another discount:
"output": {
"discountApplicationStrategy": "ALL",
"discounts": [
{
"message": "TSXB798XASFD",
"targets": [{ "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 1 } }],
"value": { "fixedAmount": { "amount": "3", "appliesToEachItem": false } }
}
]
}
Result: Total discount = 6, but line 1 is being over-discounted.
Expected behavior
Identical discounts (same code/message and logic) should be grouped into a single line in the order summary, without requiring us to merge targets manually (which breaks multi-discount scenarios).
This would improve clarity and prevent inflated totals when combining discounts.
Additional context
Merging discount targets causes incorrect allocation when combining product discounts. A visual grouping by message/code in the order summary would solve this issue without affecting logic or needing backend changes.
Thanks