Articles on: Regios Discounts

My Discount Stops Working When There Are Many Items In The Cart!

Are you noticing your discount stop working when a certain number of items are in the cart? Or are you seeing your discount only apply in the cart/checkout sometimes?


The problem you're facing is because Shopify Functions, where our app runs code on Shopify's servers, has strict limits on how much it can handle at once. This is why your discounts aren't applying correctly when the cart gets full.


Workarounds

You could try setting up more discounts, where each one has fewer conditions. This way, each discount remains simpler and is less likely to hit Shopify's limits.


For example, if you have a discount that checks for 5 different collections, you could try creating 3 discounts, where each only checks for 1-2 collections.


Shopify lets you set up to 25 different automatic discounts.


If this doesn't work, there's another trick you might try, which you can find here:

Regios Tech Workaround for App-Based Discounts Limit.


FAQs

When am I likely to have this issue?

This issue can occur when you have a logic flow that is complex. Having about 5 to 8 "Check If" steps is an indicator of a complex logic and such logic hits the limit quickly.


Or, you may be checking for multiple collections in a discount, especially if the number is 4, 5, or higher.


Do I make my discounts have a single condition?

It doesn't necessarily have to be just 1 condition per discount. But the more conditions, the more likely you will hit the limit.


Technical information

The Shopify Functions API places a limit of 11 million WebAssembly instructions executed when running a Function on any cart with fewer than 200 line items. After 200, the limit scales proportionally. However, the vast majority of orders are below 200 line items, and they all share the same constraints.


For further details, we recommend checking Shopify's documentation on the Functions API:


What factors contribute to hitting the limit?

Overall, the bigger the input data, and the more complex your logic, the faster you will hit this limit. However, the size of the input data has a far bigger impact than the actual complexity of the logic.


  • Customer/product tags/collections: The more tags/collections you query, the bigger the input data, and it grows linearly with each one. For example, if your discount checks for 5 separate tags, then the input data includes 5 additional JSON objects, one for each of those tags. This adds up quickly.
  • Cart size: More cart lines -> bigger input data -> more instructions
  • Complex logic: More conditions/branches -> more work to do per cart line -> more instructions


Shopify provides data about the cart to our app's discount in a format called JSON. This is a text-based format, so in order for computers to understand, they must perform a process called parsing. Even when using the fastest possible parsing algorithms, the number of instructions executed scales at least linearly to the size of the input data.


What measures have you taken to work around this limit?

Our app's discount logic is highly optimized to execute as few instructions as possible, but JSON parsing inherently requires many instructions.


Common misconceptions

  • Discounts are not applied as items are added to the cart. Instead, the entire cart is sent by Shopify to our app's discount as input for discount calculations. This means that the discount logic evaluates the entire cart at once, which can lead to hitting the instruction limit on larger input data.
  • There’s no difference in how Shopify handles instruction limits for discount codes and automatic discounts. Both are subject to the same constraints.
  • The quantity of each item has a negligible impact on performance; it's about the number of cart lines. For example, 1 x Product A and 50 x Product A would have roughly the same impact. But if Product A has 50 variants, and you have 1 of each in the cart, that's 50 cart lines, which means way bigger input data.


Your Feedback Matters

As a solo founder, your experience is crucial to me. Could you spare a moment to share your thoughts? Please leave a review on the Shopify App Store. Thank you for helping me improve!

Updated on: 27/06/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!