Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Using Flow, when new orders come in, can we access the Line Item Properties? If so, how?
Thanks!
Solved! Go to the solution
This is an accepted solution.
I did find resolution in apps such as: Order Tagger, Easy Tagging, Order Automator.
This is an accepted solution.
In case anyone comes across this looking for an answer Flow can now access both order properties and line item properties. In the GraphQL API that Flow uses they are called Custom Attributes. Find them at Order / customAttributes and Order / LineItems / customAttributes.
Anyone figure this out?
Hi @JCAndrea ,
you can access Line Items, it just depends what attribute/property of the line item you are trying to use. Could you clarify if you are you trying to access them for use in your message templates or, to analyse them as part of a condition?
To access line items for use in your conditions, if you create a new Flow, choose Order Created as the trigger and then for the Condition, type "line" into the conditions search box and then scroll down to the Order category where you will find Line Items:
Once you have selected line items, you'll need to select how you'd like the Condition to match:
... then you'll be presented with a long list of line item related criteria to select from:
If none of those suit your needs, could you provide a bit more information about what it is that you're trying to achieve with this Flow please?
Thank you U_Jones_UW, that was a helpful tutorial for accessing the line item object.
What I, and I believe others in this thread are trying to accomplish, is to specifically access order.line_items.properties, which are the custom fields associated with order line items.
You can see what I'm talking about here, about halfway down the page: https://shopify.dev/docs/themes/liquid/reference/objects/line_item
But, it is mysteriously missing from the Flow template variables: https://help.shopify.com/en/manual/shopify-plus/flow/create-workflow/variables
In my case, I use an app called infinite options, that stores custom engraving text in a line_item.properties field. I'm trying to get flow to pull it out and put it in a spreadsheet. No luck so far.
I do apologize, I should have read that one a bit more carefully.
I've not previously seen the ability to analyse the line item properties within Flow, so it does appear to be missing.
You may therefore need to use an app that can analyse the order line item properties first and then apply tags to the order based on a set of conditions that you specify. You could then build your workflow around the presence or absence of those tags.
We operate an app called Order Tagger that has a criteria that can do that, but I'm sure there are other apps and solutions out there that could do something similar. It may be an option you can look into until support for line item properties in Flow is supported.
Sorry for the misunderstanding!
This is an accepted solution.
I did find resolution in apps such as: Order Tagger, Easy Tagging, Order Automator.
This is a feature I would like to see implemented. Currently I am using Arigato Automation to get the task done (in my case, updating the order note based on order line item custom attributes).
Ideally we would be able to access the order.lineItems.customAttributes object within flow!
Hi,
Shopify flow seems to be missing some of the common attributes within the condition rules. Putting aside the inability to create a rule based on the line item custom attribute, which would be ideal for the case I'm trying to solve, there's nothing that can be used as a substitute.
For example, instead of adding custom attributes to order line items, we could tag the products, or have them be of certain type and use that as a trigger, but the only option there is product title:
Is there a plan to add these to the condition building? Any other suggestion (beside adding another app from store) would be very welcome
@JCAndrea Search in shopify flow: line item or title and drill down to find this:
Title
lineItems_item.title
This will target line items in the order including title...
This is an accepted solution.
In case anyone comes across this looking for an answer Flow can now access both order properties and line item properties. In the GraphQL API that Flow uses they are called Custom Attributes. Find them at Order / customAttributes and Order / LineItems / customAttributes.
Paul Thanks for this information. I am trying to add lineItem properties for each lineItem to an excel sheet in Flow. My lineitem properties is a list of strings.
{{lineItemsForeachitem.customAttributes}} variable doesn't output the list.
It gives an error: The ability to directly output objects is no longer supported. In order to make changes to this workflow, please specify the fields you need to use.
Any insight on this? Thanks
Oi paul
Você pode disponibilizar um modelo?
Not sure what template you would need, but the liquid part is documented here: https://help.shopify.com/en/manual/shopify-flow/reference/variables#complex-data-objects
Eu criei um fluxo assim:
gatilho: pedido criado
condições: o pedido é completamente pago e contem uma tag"product-personalizer"
ação: enviar um e-mail interno mostrando cada item do pedido e logo abaixo os itens de linha personalizados, incluindo urls das imagens e anexos.
Mas por algum motivo, o meu fluxo está ficando desconfigurado.
Ele mostra os primeiros dados, mas os itens de linha aparecem de forma repetida.
Quero que os itens de linha apareçam embaixo do produto equivalente, pois cada produto possui opçoes de personalização diferentes.
Voce pode me ajudar a ajustar este codigo?
Assunto (este funciona corretamente)
{{order.name}} - {{order.customer.firstName}}{{order.customer.lastName}}
----------------
Resumo do pedido:
{% for a in order.lineItems %}
Produto: {{a.title}}
SKU: {{a.sku}}
Preço (por unidade): $ {{a.originalUnitPriceSet.shopMoney.amount}}
Quantidade: {{a.quantity}}
Ítens de Linha:{% for lineItems_item in order.lineItems %}
{% for customAttributes_item in lineItems_item.customAttributes %}
Metafields {% for metafields_item in lineItems_item.product.metafields %}
{{metafields_item.value}}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
Ao final, quero mostrar de forma resumida:
Informaçoes do cliente, incluindo e-mail e telefone
Nome completo
E-mail
Telefone
Endereço de faturamento.
Este é meu primeiro fluxo e eu quero ficar expert neste assunto.
The lineItems appear multiple times because you are looping over lineItems inside of a lineItems loop.
Instead of
Line Items: {% for lineItems_item in order.lineItems %}
{% for customAttributes_item in lineItems_item.customAttributes %}
Metafields {% for metafields_item in lineItems_item.product.metafields %}
{{metafields_item.value}}
{% endfor %}
{% endfor %}
Do
Custom attributes:
{% for customAttributes_item in a.customAttributes %}
Metafields {% for metafields_item in a.product.metafields %}
{{metafields_item.value}}
{% endfor %}
{% endfor %}
I'll add that looping over metafields is no longer recommended. If you need a metafield value, you should add each individually via the "metafield" (not "metafields") variable.
I'm almost there:
Expected result for each product in the order:
Order summary
STEP 1 (LINE ITEM DATA) --------->
Order Summary:
Product: PRODUCT NAME
Option: SELECTED VARIATION
SKU:PRODUCT SKU
Price: PRODUCT PRICE
Quantity: PRODUCT QUANTITY
STEP 2 (SHOW CUSTOM ATTRIBUTES FOR LINE ITEM)
attribute 1: value 1
attribute 2: value 2
attribute 3: value 3
attribute 4: value 4
STEP 3 (METAFIELDS FOR LINE ITEM)
Category: metafield value
Style: metafield value
My code returns all variables correctly, however, in a loop or with "mixed" data
I've tested every possible way.
Please give me a tip on how to renew this code.
I need to keep this information in order, as I showed above, but I'm not having any luck.
I spent the whole day studying this.
-----------
my current code: (returns all data, however, disorganized or in looping)
<b>STEP 1 (LINE ITEM DATA)</b><br />
<b>Resumo do pedido:</b><br />
{% for a in order.lineItems %}
{% for lineItems_item in order.lineItems %}
<b>Produto:</b>{{a.title}}<br />
<b>Opção:</b>:<br />
{{lineItems_item.variantTitle}}<br />
<b>SKU:</b> {{a.sku}}<br />
<b>Preço</b> $ {{a.originalUnitPriceSet.shopMoney.amount}}<br />
<b>Quantidade:</b> {{a.quantity}}<br />
<b>STEP 2 (SHOW CUSTOM ATTRIBUTES FOR LINE ITEM)</b><br />
{% for customAttributes_item in lineItems_item.customAttributes %}
{% for customAttributes_item in a.customAttributes %}
<b>STEP 3 (METAFIELDS FOR LINE ITEM)</b><br />
{% for metafields_item in a.product.metafields %}
{% for value_item in lineItems_item.product.categoriadejaleco.value %}
<b>Categoria:</b> {{value_item}}
{% for lineItems_item in order.lineItems %}
{% for value_item in lineItems_item.product.estilodejaleco.value %}
<b>Estilo:</b> {{value_item}}
{% for lineItems_item in order.lineItems %}
<b>Características:</b> {{value_item}}
{% for value_item in lineItems_item.product.caracteristicadejaleco.value %}
{{value_item}}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
This code is not close. You should never be looping over the same list twice. You loop over lineItems about 5-6 times, in nested loops. That would results in hundreds of loops and probably your workflow will hit an API limit if it get's that far.
I think this will at least run, assuming that your metafield I put in there is named correctly is and is a list of strings. If you add more, make sure they follow that same li.product.<name> format (you might need to delete the order/lineItems loop it inserts). Or just fix up the ones you have already.
<b>STEP 1 (LINE ITEM DATA)</b><br />
<b>Resumo do pedido:</b><br />
{% for li in order.lineItems %}
<b>Produto:</b>{{li.title}}<br />
<b>Opção:</b>:<br />
{{li.variantTitle}}<br />
<b>SKU:</b> {{li.sku}}<br />
<b>Preço</b> $ {{li.originalUnitPriceSet.shopMoney.amount}}<br />
<b>Quantidade:</b> {{li.quantity}}<br />
<b>STEP 2 (SHOW CUSTOM ATTRIBUTES FOR LINE ITEM)</b><br />
{% for ca in li.customAttributes %}
{{ ca.key }}-{{ ca.value }}
{% endfor %}
<b>STEP 3 (METAFIELDS FOR LINE ITEM)</b><br />
{% for value_item in li.product.caracteristicadejaleco.value %}{{value_item}}{% endfor %}
{% endfor %}
Thank you!
One of the metafields has many values.
example:
{% for value_item in li.product.characteristicadejaleco.value %}{{value_item}}{% endfor %}
Output:
BLUE, RED, YELLOW, PURPLE
This used to work, but now it doesn't.
I need to separate these values with a comma or dash (-)
What do you suggest?
I'm almost there:
Expected result for each product in the order:
Order summary
STEP 1 (LINE ITEM DATA) --------->
Order Summary:
Product: PRODUCT NAME
Option: SELECTED VARIATION
SKU:PRODUCT SKU
Price: PRODUCT PRICE
Quantity: PRODUCT QUANTITY
STEP 2 (SHOW CUSTOM ATTRIBUTES FOR LINE ITEM)
attribute 1: value 1
attribute 2: value 2
attribute 3: value 3
attribute 4: value 4
STEP 3 (METAFIELDS FOR LINE ITEM)
Category: metafield value
Style: metafield value
My code returns all variables correctly, however, in a loop or with "mixed" data
I've tested every possible way.
Please give me a tip on how to renew this code.
I need to keep this information in order, as I showed above, but I'm not having any luck.
I spent the whole day studying this.
-----------
my current code: (returns all data, however, disorganized or in looping/repeat data)
<b>STEP 1 (LINE ITEM DATA)</b><br />
<b>Resumo do pedido:</b><br />
{% for a in order.lineItems %}
{% for lineItems_item in order.lineItems %}
<b>Produto:</b>{{a.title}}<br />
<b>Opção:</b>:<br />
{{lineItems_item.variantTitle}}<br />
<b>SKU:</b> {{a.sku}}<br />
<b>Preço</b> $ {{a.originalUnitPriceSet.shopMoney.amount}}<br />
<b>Quantidade:</b> {{a.quantity}}<br />
<b>STEP 2 (SHOW CUSTOM ATTRIBUTES FOR LINE ITEM)</b><br />
{% for customAttributes_item in lineItems_item.customAttributes %}
{% for customAttributes_item in a.customAttributes %}
<b>STEP 3 (METAFIELDS FOR LINE ITEM)</b><br />
{% for metafields_item in a.product.metafields %}
{% for value_item in lineItems_item.product.categoriadejaleco.value %}
<b>Categoria:</b> {{value_item}}
{% for lineItems_item in order.lineItems %}
{% for value_item in lineItems_item.product.estilodejaleco.value %}
<b>Estilo:</b> {{value_item}}
{% for lineItems_item in order.lineItems %}
<b>Características:</b> {{value_item}}
{% for value_item in lineItems_item.product.caracteristicadejaleco.value %}
{{value_item}}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
Parece que agora consegui fazer funcionar.
Fiz alguns ajustes no código e estou testando com os pedidos.
Não estou mais conseguindo mostrar os metafields separados por virgula.
pode me ajudar?
Resultado esperado:
metafield_name1: value1, valu2, value3 etc
metafield_name2: value1, valu2, value3 etc
Put a comma after the value variable
Hi Paulo! I managed to do it. I made some adjustments and now it works perfectly.
Now I need to create a flow so that for each order created, a line with each item of the order is added to Google Sheets. I have done many tests and it works, however, I cannot bring the properties of the line items of the products (customattributes). And I also cannot create a line for each product purchased.
Here is an example of the expected result:
Note that it is the same order,
however, a line was created for each product.
Can you help me adjust this?
Some variables I'm using:
{{order.name}},
{{lineItemsForeachitem.title}},
{{lineItemsForeachitem.quantity}},
{{lineItemsForeachitem.originalTotalSet.shopMoney.amount}}
I have so many tested flow codes here that I preferred not to send them to you, to avoid confusion.
This was the last flow I tested to capture line item attributes, but it didn't work:
{{order.name}}, {{lineItemsForeachitem.title}}, {{lineItemsForeachitem.quantity}}, , {{lineItemsForeachitem.customAttributes}}, R${{lineItemsForeachitem.originalTotalSet.shopMoney.amount}}
This flow is incomplete and unformatted, it was just for testing.
I need a flow that gives me the expected result in the image above.
I ACHIEVED
see my flow:
{{ order.name }}, {{order.createdAt}},{{order.customer.displayName}},{{order.shippingAddress.name}}-{{order.shippingAddress.address1}}-{{order. shippingAddress.address2}}-{{order.shippingAddress.zip}}-{{order.shippingAddress.city}}-{{order.shippingAddress.province}},{% for fulfillmentOrders_item in order.fulfillmentOrders %}
{{fulfillmentOrders_item.order.shippingLine.carrierIdentifier}},
{% endfor %}
{{ lineItemsForeachitem.title }},
{{ lineItemsForeachitem.sku }},
{{ lineItemsForeachitem.quantity }},
{% for li in order.lineItems %}
{% assign customAttributesString = '' %}
{% for ca in li.customAttributes %}
{% assign customAttributesString = customAttributesString | append: ca.key | append: ' - ' | append: ca.value | append: '\n' %}
{% endfor %}
{{ customAttributesString | strip_newlines }}
{% endfor %}
however, it is still not showing ONLY the attributes of the equivalent item.
I need only the attributes of the item shown in the line to be shown.
Example:
LINE 1
ITEM 1
ATTRIBUTES 1
LINE 2
ITEM 2
ATTRIBUTES 2
I also couldn't find the variables for this request data:
Carrier name
Shipping method.
Can you help me with this?
I'm not sure why you are using a variable to store the customAttributes, since you could just output them instead. For example in that loop, just:
{{ ca.key }}-{{ca.value}}
The problem with your code is that you created a variable and are appending to it, but you never clear it before the next line item. So either remove the variable or do an {% assign customAttributesString = "" %} after you output it.
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024