Users are encountering errors when trying to use Liquid code in Shopify Flow, specifically receiving “invalid variable” messages when attempting to access order line items.
Core Issue:
Flow Liquid syntax differs from storefront Liquid syntax
The correct variable name is order.lineItems (not order.line_items)
Array items cannot be accessed using bracket notation like options[0] or options[1]
Key Solution Provided:
Use Flow’s “Add a variable” feature to identify correct syntax
Loop over arrays using {% for li in order.lineItems %} instead of direct indexing
Reference Shopify’s Flow-specific documentation rather than general Liquid docs
Remaining Problem:
One user reports that even when using the exact syntax from “Add a variable” (including lineItems_item), they still receive invalid variable errors. This suggests a potential inconsistency between Flow’s variable suggestion tool and what the system actually accepts.
The discussion remains open with the last reported issue unresolved.
Summarized with AI on October 24.
AI used: claude-sonnet-4-5-20250929.
Can anyone tell me why this code refuses to be accepted by Shopify Flow please?
{% for line_item in order.line_items %}
{% if line_item.product.metafields.availability contains ‘NOT Available’ or line_item.product.metafields.logistics contains ‘Item is not available to order’ %}
{{line_item.sku}}
{% endif %}
{% endfor %}
It looks like the error message is indicating that the variable “line_items” is not valid and needs to be replaced.
Some possible causes of this error could include:
“line_items” is not a valid variable within the context of your code
There is a typo in the variable name, and it should be “line_item” instead
You are using an outdated version of Shopify’s Liquid template language and the variable name has been changed or deprecated.
I would recommend double-checking the variable name and making sure it is spelled correctly and that it is a valid variable in the context of your code. Also, check the version of the liquid template, if it is outdated, update it. Also, you can check Shopify’s documentation for the version you’re using to ensure that the variable is still supported.