The issue I’m facing is that when I create multiple discounts, the function runs once for each, and it only keeps one. It seems like selectionStrategy: "All"
might have a bug, it behaves as if it were set to "MAXIMUM"
, since only the highest discount is applied.
Maybe I’m missing something, but I’ve gone through the docs, types, and lots of tests — no luck so far.
I’d really appreciate any guidance. Thanks!
Hi @teocorona
Can you share your request parameters for further analysis of the problem
Sure!
I’m returning this array.
const operations: CartLinesDiscountsGenerateRunResult['operations'] = [];
// code...
operations.push({
productDiscountsAdd: {
candidates: productWithDiscount?.map((product) => {
return {
message: `${product.discount}% OFF PRODUCT`,
targets: [
{
cartLine: {
id: product.lineId,
},
},
],
value: {
percentage: {
value: product.discount,
},
},
}
}),
selectionStrategy: ProductDiscountSelectionStrategy.All,
},
});
return {
operations
}
The input query if it’s helpful
query CartInput {
cart {
lines {
id
merchandise {
... on ProductVariant{
product{
id
}
}
}
}
}
discount {
discountClasses
metafield(
key: "function-configuration",
namespace: "$app:bundle-discount"
){
value
}
}
}
Only one discount can apply at an individual cart line, and Shopify will apply the best one.
Multiple discounts at the product level is on the roadmap for Q1 2026 (Apps in checkout)
Hi,
You’re not alone — this behavior is actually by design. When multiple discounts apply to the same cart, Shopify Functions will typically select one discount per item based on the selection strategy. Even with selectionStrategy: "ALL"
, it doesn’t stack discounts across the same product line; instead, it allows multiple discounts to apply if they target different items. Stacking discounts on the same item usually requires custom logic or a different function approach.
Thanks for your aswers @kyle_liu @bkspace @Isiaq_Oni_936 !!
I’m trying to apply one discount per item, not stack multiple discounts on the same item.
However, the function runs once per discount, and only the highest discount is applied.
@teocorona :
All discount functions are unaware of each other and will calculate price for each product and pass it to shopify.
Shopify internal code logic will check for the best rate that applies and that will be considered when the cart is displayed.
So though all discount code wil be executed but for a given product only one of the functions discount( best price or minimum price ) will be the final outcome.
The purpose of selection strategy is to allow all functions to get executed if set to ALL is my understanding.
Thanks @Ankit_Shrivastava !
I get your point, but regarding the selection strategy — this is what’s defined in Shopify’s types.
export enum ProductDiscountSelectionStrategy {
/** Apply all the discount candidates to eligible cart lines. This doesn't override discount combination or stacking rules. */
All = 'ALL',
/** Apply the first discount candidate to cart lines that satisfies conditions. */
First = 'FIRST',
/** Apply the discount to the cart line that offers the maximum reduction. */
Maximum = 'MAXIMUM'
}