Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hey there I am trying to get shopify flow to give the sku for the out of stock item as well as the name. (if not possible, just the SKU is fine.)
Right now it gives a list of the most recently sold 100 items out of stock but only the item title.
Here is the code I am using:
Items out of stock:
{% for getProductData_item in getProductData %}
- {{getProductData_item.title}}{% for getProductData_item in getProductData %}
{% for collections_item in getProductData_item.collections %}
{% for products_item in collections_item.products %}
{% for variants_item in products_item.variants %}{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
I'm glad you know to ask so I'll say - DON'T RUN THAT CODE. You are repeatedly looping over up to 100 items and all collections and all variants. You will likely hit an API rate limit and it will never complete.
It's a bit unclear why you are using "Get Product Data", but assuming you want a report of multiple out of stock items that might be the way. The problem though with "Product" is that each Product has multiple variants. Inventory and SKUs are at the variant level. So you could either switch to "Get Product Variant Data" or use something like:
{% for getProductData_item in getProductData %}
- {{getProductData_item.title}}
{% for variant_item in getProductData_item.variants %}
- {{ variant_item.sku }} - {{ variant_item.title }} - {{ variant_item.inventoryQuantity }}
{% endfor %}
{% endfor %}
The code I am using is supposed to give me only the items that have sold out in the last 24 hours every day, so we can see the most recently sold out items. Ideally we would just want things that sold out in the last day from the POS retail location but that seems like more work than we know what to do with. Your suggestion helped except it doesn't limit to what sold in the last day. I know some of the items that it returns we haven't had in a long while.
The Getproductdata part of the flow has this custom code but it seems to be giving out whatever has sold out in general.
updated_at:<='{{ scheduledAt }}' AND updated_at:>'{{ scheduledAt | date_minus: "1 day" }}'
inventory_total:<=0
The API does not have a way to get products that recently went out of stock. Updated_at doesn't work because there are many reasons for an update (like it was sold or a tag was added).
What you could do is tag products that go out of stock using a separate workflow with the date. Then you can add a "tag:sold_out_01_01_24" or something like that to your query. You'll probably need to also have a process for removing those tags, like when they go back in stock.
Thanks, I wanted only the SKUs and their quantity for low stock and out of stock (which will be always 0) but in case it goes in minus.
Below worked fine with me.
Items out of stock:
{% for getProductData_item in getProductData %}
{% for variant_item in getProductData_item.variants %} - {{ variant_item.sku }}
{% endfor %}{% endfor %}
Items Low stock:
{% for getProductData_item in getProductData %}
- {{getProductData_item.title}}
{% for variant_item in getProductData_item.variants %}
- {{ variant_item.sku }} - {{ variant_item.title }} - {{ variant_item.inventoryQuantity }}
{% endfor %}
{% endfor %}
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025