I’m using this flow template but am getting this error when running:
I crossed out the location but it does return a correct name. I didn’t change anything in the template.
Can someone tell me why/how to fix the error?
Thanks in advance!
A user encountered an error while implementing a Shopify Flow template designed to add a free (100% discounted) item to new orders. The error occurred because location_inventory was returning as undefined.
Root Cause:
Solution:
Status: Resolved after the user updated the location name in the code.
I’m using this flow template but am getting this error when running:
I crossed out the location but it does return a correct name. I didn’t change anything in the template.
Can someone tell me why/how to fix the error?
Thanks in advance!
Your post is missing the most important part of all - the console.log output. Based on the available information, location_inventory is probably undefined, which means no item in the array met your criteria.
It’s a good idea to check for null/undefined when working with data in JavaScript.
In that code, it’s finding a location by it’s name (‘Enter a unique part of the location name here’). You need to substitute the name of your location there.
Thank you! That worked. Silly me didn’t realize I was suppose to edit that. ![]()