Solved

How to add inventory levels to a flow in Google Sheets?

amellick
Tourist
7 0 1

Hi I'm using a flow that adds line items of new orders to a Google Sheet. I want to add the stock level of each line item in a particular location to the spreadsheet (I will specify the location)

Can you please assist with the variable to add to the flow - see image below

 

 

flow1.jpg

Accepted Solution (1)
paul_n
Shopify Staff
946 128 225

This is an accepted solution.

,{%- for level in lineItemsForeachitem.variant.inventoryItem.inventoryLevels -%}
{% if level.location.name == "Your location name" %}{{ level.available }}{% endif %}
{%- 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.

View solution in original post

Replies 5 (5)

Digico
Shopify Partner
46 1 4

Hi, 

Issue is inventory_stock_level is not available where you ask for it (at order level). Maybe you can make 2 separate flows to fill your Google Sheets.

Another way would be to make a private app and query GraphQL directly (you can do it inside Flow too).

https://shopify.dev/docs/api/admin-graphql

paul_n
Shopify Staff
946 128 225

Order / lineItems / variant / inventoryItem / inventoryLevels / location / name

and 

Order / lineItems / variant / inventoryItem / inventoryLevels / available

 

You would need to loop over the levels in your liquid code.

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.
amellick
Tourist
7 0 1

Thanks Paul - how would I add this to the end of the row (current contents below)

 

{{ order.name }},{{order.createdAt}},{{lineItemsForeachitem.quantity }},{{lineItemsForeachitem.sku }},{{lineItemsForeachitem.title}} - {{lineItemsForeachitem.variant.title}},{{lineItemsForeachitem.vendor}},{{order.customer.displayName}},{{lineItemsForeachitem.discountedTotalSet.shopMoney.amount}},

 

 

paul_n
Shopify Staff
946 128 225

This is an accepted solution.

,{%- for level in lineItemsForeachitem.variant.inventoryItem.inventoryLevels -%}
{% if level.location.name == "Your location name" %}{{ level.available }}{% endif %}
{%- 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.
amellick
Tourist
7 0 1

Hi Paul - the last couple of days the flow has been exporting the price pid for line items EXCLUDING tax but it should be exporting the line item INCLUDING tax.
{{lineItemsForeachitem.discountedTotalSet.shopMoney.amount}},
Has Shopify changed this variable?