Add free (discounted 100%) item to new orders

Solved

Add free (discounted 100%) item to new orders

Axr162
Excursionist
14 0 13

I'm using this flow template but am getting this error when running: 

Axr162_0-1746040028629.pngAxr162_1-1746040223735.png

I crossed out the location but it does return a correct name.  I didn't change anything in the template.

Axr162_2-1746040337587.png

Can someone tell me why/how to fix the error?  

 

Thanks in advance!

Accepted Solution (1)

paul_n
Shopify Staff
1771 194 414

This is an accepted solution.

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.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 3 (3)

tobebuilds
Shopify Partner
581 42 157

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.

Founder, Regios Discounts app (4.8 stars, 94 reviews)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer
- Often imitated, never duplicated

paul_n
Shopify Staff
1771 194 414

This is an accepted solution.

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.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Axr162
Excursionist
14 0 13

Thank you!  That worked.  Silly me didn't realize I was suppose to edit that. 😅