Personalized checkout and custom promotions with Shopify Scripts
Having an issue with cart scripts stacking with function discounts. If I use a generic shopify discount code it stacks with the cart script meaning some items have 2x discounts which is expected, however if I then create a discount code via a function discount, it no longer stacks with the script discount and all items have 1 discount from the function, is this a bug?
So:
native shopify discount code + cart script = stacks discounts
function discount code + cart script = doesn't stack, function discount is always applied
I know that the script + function discount is applied because I've been in the same situation as you. Have you made the combination selection? Maybe the issue is related to that. I want to help you, but I need more details. Can you provide more information?
Yeah have tried changing the combination settings and nothing changed unfortunately. Even with a native shopify discount and the combinations disabled it still stacked with the script discount (as I believe combinations are just for multiple shopify discounts rather than discounts + scripts). I tried the function discount with all combinations enabled and disabled and the outcome was the same, only the function discount was being applied
Don't you want Script + Function discounts to work together?
I'm running both function discount and script discount together. There might be another issue. It requires checking the codes. I don't have any issues; it works in both scenarios.
It seems it's because it's causing the script to error when the function is running
I'm getting a "can't convert nil into Decimal" error, even with the simplest line item script possible which doesn't make sense:
Output.cart = Input.cart
Since I can't see the exact line that is causing the error, I can't specify its exact location. However, if you perform a nil check before the line that is causing the error, the issue should be resolved.
Hi,
The full script contents is the following (only 1 line) and the error is still being caused:
Output.cart = Input.cart
Screenshot here also:
It doesn't give me any errors either. Shopify scripts are behaving a bit oddly, but I am sure that 1 script 1 function is working because I have tested the same combination, and both are working simultaneously. To understand the problem you are experiencing, a detailed examination is necessary. It seems like you opened a single-line code to test. If you delete the current script and create a new empty script, the issue should be resolved. I would be happy to assist. I am looking forward to your responses.
Hello did you find a solution for that?
I think it was a momentary mistake. Do you have such a mistake?
I tried a new blank script and was still getting the error
Found a thread on the shopify partners slack with the same issue, seems like it's a known issue - https://shopifypartners.slack.com/archives/C0225DTE1M1/p1697560174116759
can you show your url when you press the debug button?
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025