3 limitations of Shopify Scripts (and how you can work around them)
Jan 24th, 2022
If you have worked with Shopify Scripts for any bit of time you likely are aware of the fact you can only have one shopify script running at a time.
This can be extremely annoying if you operate a supplement brand on Shopify Plus where you sell hundreds of products across several vendors. Each vendor offers different promotions at various periods of time so having the flexibility to run several different types of promotions at the same time becomes critical to running your Shopify Plus store.
Brand1 - Offering Buy 2 Get 1 Free
Brand2 - 20% Off
Brand3 - 20% off If you buy 2 or more
Even though you can setup one shopify script for line items, one shipping script and one payment scripts all running at the same time using the Shopify Script Editor, you cannot have more than one of the same type of Shopify Script running at the same time.
The workaround for this is that you combine multiple line item scripts into a single line item script within the Shopify Script Editor.
New to Shopify Scripts? Learn about the three types of Shopify Scripts you can create within the Shopify Script Editor.
How to combine multiple shopify scripts into a single script
Using the three promotions mentioned above, here is how you could combine multiple promotions into a single Shopify Script.
Brand 1: Buy 2 Get 1 Free
Brand 2: 20% Off Sitewide
Brand 3: 20% Off If You Buy 2 or More
The trick when combining multiple Shopify Scripts in the Shopify Script Editor is to use different variable names and understand how one script may impact another based on the order within the Shopify Script Editor.
In this example, this is what your single Shopify Script would look like when combined:
Need help running multiple Shopify Scripts at the same time? Our team is ready to help you combine scripts so you can run several promotions at the same time.
2 Other Limitations of the Shopify Scripts Editor
Combining multiple shopify scripts into a single script within the Shopify Scripts Editor is great for allowing several types of promotions to run at the same time.
What you might not realize is there are two other limitations you might face when combining Shopify Scripts.
Lines of Code in Shopify Script Editor
The first limitation of the Shopify Script Editor is that there is a limit to the number of lines of code you can put into a single script. This means when combining multiple scripts you run the risk of hitting this limit.
Though Shopify has increased the limit from 1000 to 2000 lines of code, it is still quite common for supplement brands reselling other brands to experience this limitation of the Script Editor.
The best way to avoid this limitation within the Script Editor is to reuse variables as best as possible and to limit the number of comments within your code. Normally adding comments is a good thing, but when trying to free up more lines this works well.
CPU Limit in Shopify Script Editor
The second limitation of the Shopify Script Editor is that there is a CPU limit. You might experience this when combining Shopify Scripts within the Script Editor. This means if your Shopify Script is too slow to fully execute then Shopify won’t let you enable your script.
The best way to avoid this limitation within the Script Editor is to write highly performant code that takes advantage of the Ruby language and functions available to you.
If you find yourself hitting the CPU limit and would like one of our Shopify Script experts to take a look then reach out. We can usually have a Shopify Scripts audit complete within 48 hours.
Looking for help with Shopify Scripts?
Whether you need a script built from scratch, have questions if a script is possible or want us to update your current script we can help!
Just reach out to us and one of our Shopify Script Experts will get back to you as soon as they can.