Order discount - product variant target quantity does nothing

Topic summary

Order-level discount functions are misbehaving: targeting a specific product variant with quantity set to 1 still discounts all quantities of that variant once the cart threshold is met. Disabling other discounts doesn’t change the outcome.

Further issues reported: excludedVariantIds in orderMinimumSubtotal conditions appear ignored, causing excluded items to count toward thresholds. Example code shows excludedVariantIds used in both conditions and targets, yet discounts still trigger.

Update: Shopify acknowledged a platform bug and said a fix would ship after Black Friday/Cyber Monday (BFCM).

Additional concerns: lack of clear customer feedback for invalid product discount codes and uncertainty about where the message field surfaces. One user observed an ineligible item receiving a discount after removing eligible items from the cart.

Recent reports suggest a partial/unfinished fix: excludedVariantIds works in the store’s default currency (USD) but fails in other currencies. A suspected legacy path calculates thresholds in USD, ignores exclusions, applies only the first tier, and disregards the Maximum application strategy. Code snippets are central to these findings.

Status: unresolved/ongoing. Key open items: correct enforcement of variant quantity targeting, consistent excludedVariantIds handling across currencies, and clarity on discount message/invalid-code feedback.

Summarized with AI on December 26. AI used: gpt-5.

I am currently building an order discount function that should make specific line items free when a certain cart value is reached. Since I want to include line level discounts applied by some product discount functions in the cart value, I am using the order discount instead of a product discount function. In product discount functions, those line level discounts seem to be not reflected in the cart input.

The order discount function run result allows targeting product variants and also specifying a quantity. My function run result includes a product variant target with a quantity of 1, as you can see below:

{
  "discountApplicationStrategy": "FIRST",
  "discounts": [
    {
      "conditions": [
        {
          "orderMinimumSubtotal": {
            "excludedVariantIds": [
              "gid://shopify/ProductVariant/37732318707871"
            ],
            "minimumAmount": 100,
            "targetType": "ORDER_SUBTOTAL"
          }
        }
      ],
      "message": "Aktion",
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/37732318707871",
            "quantity": 1
          }
        }
      ],
      "value": {
        "percentage": {
          "value": 100
        }
      }
    }
  ]
}

But when I add more quantity of this product to my cart, they are discounted too. I only want a quantity of 1 to be discounted. This seems like a bug to me, or what does the quantity in the function run result do?

I am happy for any help on this, thanks in advance!

Hi VitaDev,

Could there be another discount function or rule in your cart that is also applying a discount to the same product variant? You’ll want to make sure to check all your discount functions and rules to ensure there are no conflicts.

Hey Liam,

Thanks for you quick reply. I had other discount functions active, but none of them applied discounts to the same line item / product variant. Deactivating them changes nothing, the problem remains the same.

Hi VitaDev,

I’ve reached out to our product team on this to confirm that the use case you’re trying to achieve is supported with order discount functions. Will update here when I learn more.

1 Like

I’ve been having problems with excludedVariantIds too. Actually, it seems like a lot of the functionalities don’t work, are poorly exemplified, or I’m just getting them wrong.

conditions:[{
          orderMinimumSubtotal: {
            excludedVariantIds,
            minimumAmount,
            targetType: TargetType.OrderSubtotal
          }
        },
        {
          productMinimumQuantity: {
            ids,
            minimumQuantity,
            targetType: TargetType.ProductVariant
          }
        }]

There, for example. I have exlucedVariantIds both in targets and conditions, but it’s still counting the excluded variants when comparing to the subtotal. So if the subtotal is over the minimum because of the excluded variants it applies the discount even though it shouldn’t. Maybe I’m doing something wrong?

I can artificially raise the minimum value by adding the cost of the unwanted variants to it, but then what’s the point of excludedVariantIds? The problem is usually me, but since I can’t find more complete examples I don’t know what I’m doing wrong.

Hi Ryoshin & VitaDev,

Our devs have identified that there is a bug on our side which is causing this. We’re working on a fix which will likely be shipped after BFCM. Thanks for flagging this!

1 Like

Ok, thanks. Another question, how do product discounts show the feedback that “discount code isn’t valid for the items in your cart” if there’s no condition field, the target can’t be empty, and EMPTY_DISCOUNT shows no feedback?

I agree, I always liked developer documentation of Shopify but regarding functions in many cases more examples and explanation would be beneficial. I also get the impression that there are quite many bugs with discount functions at the moment which makes it hard to migrate complex discount logic from scripts to functions.

Regarding the feedback if a discount is not valid for items in cart, I think there is no feedback wanted for those automatic app discounts, it can just apply discounts or not. Makes sense to me, since automatic discounts are not activated by a customer like discount codes and this kind of feedback would be more confusing than helpful.

I’m creating discount codes. I think it’s less confusing if it says “discount code isn’t valid for the items in your cart” instead of simply not applying anything. They might think the discount code isn’t working instead of knowing the products don’t fit the criteria. And I’m also talking specifically about product discounts since I’ve got it sort of figured out for order discounts with conditions. I agree they’re not as necessary for automatic discounts though.

Also, what is message supposed to do?

  • message (String)

    The discount message.

    I can’t see the result of it anywhere

Just ran into another error. I created a product discount, it applies correctly. I had 4 products in my cart, 2 fit the criteria and 2 didn’t. It applied correctly. When I removed the 2 products that fit the criteria 1 of the products that didn’t fit took the discount for itself. So a product that shouldn’t be discounted was!

You should probably create new threads for those kinds of problems you encounter so that they eventually are seen be the right people and can get fixed.

This still doesn’t work properly…

We encounter the similar issue with more complex condition, it looks like the bug was half fixed, but not entirely fixed . The “excludedVariantIds” was successfully applied for “orderMinimumSubtotal” in the condition logic in my case, but only for store default currency (which is USD in our case). In our case, we applied 4 currencies: USD, CAD, AUD, and NZD. The USD works well, but other currencies causing some problems.

Our discount logic:

const thresholds = {
		"USD": [ 89, 149, 249 ],
		"CAD": [ 119, 199, 339 ],
		"AUD": [ 129, 219, 369 ],
		"NZD": [ 139, 239, 399 ]
	}

	const discounts = [
		// first tier discount
		{
			value: {
				percentage: {
					value: 15,
				},
			},
			conditions: [
			  {
				orderMinimumSubtotal: {
				  targetType: TargetType.OrderSubtotal,
				  minimumAmount: thresholds[currencyCode][0],
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
			targets: [
			  {
				orderSubtotal: {
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
		},
		// seconnd tier discount
		{
			value: {
			  percentage: {
				value: 25,
			  },
			},
			conditions: [
			  {
				orderMinimumSubtotal: {
				  targetType: TargetType.OrderSubtotal,
				  minimumAmount: thresholds[currencyCode][1],
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
			targets: [
			  {
				orderSubtotal: {
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
		},
		// third tier discount
		{
			value: {
			  percentage: {
				value: 40,
			  },
			},
			conditions: [
			  {
				orderMinimumSubtotal: {
				  targetType: TargetType.OrderSubtotal,
				  minimumAmount: thresholds[currencyCode][2],
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
			targets: [
			  {
				orderSubtotal: {
				  excludedVariantIds: excludedVariantIds,
				},
			  },
			],
		}
	]

  	// return tier discount;
	return {
		discounts: discounts,
      	discountApplicationStrategy: DiscountApplicationStrategy.Maximum
	}

We did a huge amount of test, and found that there might be two conditions taking effect at the same time.

First condition (which is exactly what the code above shows) :

Order subtotal (excluding the variantIds we expected) meets the minimum amount we set, for whatever currency provided by the cart object. (Which is perfectly correct. This is what we want! )

Second condition ( not implemented by our code at all, but taking effect at the same time, we suspect it is the old logic in Shopify ) :
Order subtotal (doesn’t excluding the variantIds we expected) meets the minimum amount we set, ignores the currency (it supposes the currency is “USD”, not taking cart currency info into consideration), and only works for the first tier (looks like the “discountApplicationStrategy: DiscountApplicationStrategy.Maximum” is not taking effect for this logic as well).

The second condition causing issues when our store switched to other currency, since the condition was still calculated in “USD”, and it doesn’t exclude the variantIds we specified, and it somehow only apply first tier. (This is very likely matching the logic in the old code.)

So we highly suspected that the bug was fixed by adding new code, but didn’t remove the old code. For the store with only one currency, the problem looks fixed. But for multiple currencies situation, the problem stay there.

Please check with the technical person to confirm whether this bug exists or not, as this affect our business strategies. (And we are in Shopify Plus plan)