Issue with Zero-Value Order Discounts in Discount Functions

Hi everyone,

I’ve run into a strange issue with Shopify Functions and order discounts.

When I the Shopify function returns an order discount with a value of 0, Shopify throws an error saying:

“This discount can’t be combined with your existing discounts.”

But here’s the irony:

  • If I set the discount to 0.01 (fixed amount), it works fine.
  • If I enable “combine with other discounts” and keep the value as 0, it also works.
  • If I manually create a discount in the admin with 0% value and keep “combine with other discounts” off, it works too.

So the problem only happens with function-generated zero-value order discounts with “combine with order discounts” off.

My use case is that I need the discount to be zero — it’s not meant to reduce the price, but to trigger some actions.

Questions:

  • Is this a recent change in how Shopify validates discount functions?
  • Is there a way to return a 0-value order discount from a function without enabling “combine with other discounts” disabled?

I’ve attached screenshots showing the checkout error and the function output for reference.

Any insights or workarounds would be really helpful!

Thanks :folded_hands:

I think what might be helpful here is if you would be able to explain what you are trying to achieve?
It it that you want to add a free product or apply a discount code to trigger something?
That would help add some context to the problem please :slight_smile:

Thanks for the reply. The zero-value order discount is intended to trigger a free gift block. This block will add a free product to the cart, and then the discount function will return both the order and product discounts. The order discount will still be zero-valued, but the product discount will be 100%.

@Harinder_Singh: would suggest that you go for cart transform approach in such scenerios, if its possible to make out within cart transform function and add a free gift with cart transform.

1 Like