Why is my order summary code invalid in Flow?

NOMADCT
New Member
10 0 0

I'm trying to have an order summary: Order name, number, line items with variant purchased, quantity and image for said variant. 

 

{{order.customer.email}}
{{order.name}}
{% for li in order.lineItems %}
{% for li in line_item.variant %}
{{ line_item.image | img_url: 'small' | img_tag }}
{{ li.title }}
{% endfor %}

Replies 4 (4)

Dan-From-Ryviu
Shopify Partner
7726 1506 1515

Your code is missing another {% endfor %} at the end

- Helpful? Like and Accept solution or Buy me a coffee
- Ryviu - Product Reviews app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Shopee and Walmart and CSV.
- Lookfy app: Easy and fast to create Photo Gallery, Lookbook, Shop The Look
- Enjoy 1 month of Shopify for $1. Sign up now

paul_n
Shopify Staff
1012 133 243

It's also using {% for li in line_item.variant %} when line_item is not defined as a variable

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.
NOMADCT
New Member
10 0 0

So something like this? 

{{order.customer.email}}
{{order.name}}
{% for li in order.lineItems %}
{item.variant}
{{ line_item.image | img_url: 'small' | img_tag }}
{{ li.title }}
{% endfor %}

{% endfor %}

 

paul_n
Shopify Staff
1012 133 243

No. When you loop over a list, that "li" part is the single item for that iteration of the loop. So if you want to access line item info, you need to use that li. You also have a second closing {% endfor %} for no reason. To learn the basics, I definitely recommend you read up on liquid more here

 

I'll add that I'm guessing you copy/pasted this code... Flow does not support the exact same liquid as themes, so when you use tags like "img_url" and "img_tag" make sure to confirm they work, because I don't think they are supported in the variant of liquid that Flow uses. I substituted the "URL" field for those tags. This at least passes validation:

 

 

{{order.customer.email}}
{{order.name}}
{% for li in order.lineItems %}
{li.variant}
{{ li.image.url }}
{{ li.title }}
{% endfor %}

 

 

 

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.