Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
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 %}
I get the error:
Hey @vanillamt,
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:
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.
Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Same problem with this code
So first, Flow liquid is not same as storefront liquid (see https://help.shopify.com/en/manual/shopify-flow/reference/variables). Use "Add a variable" to gauge the syntax. So "order.line_items" is "order.lineItems" in Flow.
Second, you cannot access array items that way, like "item.variants.options[1]". You can loop over arrays to get their items.
Finally, I'm not sure where you got "order.lineItems_item" but that's not a field name. To access lineItems, typically you would use this loop:
{% for li in order.lineItems %}
{% if li.title == "something" %}
print out something
{% endif %}
{% endfor %}
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024