Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hello All,
I'm struggling with a flow that would let me check a specific warehouse on the event of 'Product variant inventory quantity changed'.
I have two flows that are almost identical, with the only difference being the name of said warehouse.
Here's my flow:
Ideally, this flow would sent me an email when an ACTIVE item in the AU Warehouse sells out. I have the same flow for the NZ Warehouse. Originally, the flow had conditions to check each warehouse, but I always received an email for both. As part of troubleshooting, I seperated the warehouse checks into individual flows, but I still get two emails, one for each warehouse.
When checking Recent runs, I see this:
Am I right is seeing that this condition will always be true for either warehouse, as both warehouse names are returned in the 'location / name' array? If so, that appears to defeat the purpose of specifying the warehouse name to begin with.
On top of that, the check for inventory also appears to have the stock values for both warehouses too:
I get two emails everytime there's a zero in the above check, and sometimes I get four. I'm at a loss and if anyone can point me in the right direction, it would be greatly appreciated.
Kind regards,
Nathan
You need to check the name of the location and the inventory in the same condition. In this workflow, you just loop over the same list of locations twice and check those things independently. If you search for "location inventory" in the template library, you'll find an example of what this looks like
Hi Paul,
Thanks for the reply. As suggested, I modified each flow to look like this:
As part of the test, the NZ warehouse has no stock of my test item. I manually drop the stock in the AU warehouse to zero but both flows run and I get two emails. This also happened when my original flow had the two 'check ifs', one for each warehouse. Do I need to also check 'Inventory quantity prior'?
Regarding the template library, 'location inventory' has 31 results, and the closest fit was this flow:
"Send Slack message when variant inventory is out of stock at a certain location"
This was the flow I started with and modified. Is this the one you'd recommend?
Kind regards,
Nathan
your condition show look something like this:
You could check the location ID instead of the name. You need to be checking the inventory and location on the same inventory level item...the nesting level is very important.
Hi @paul_n,
Thanks for the above. This is my new flow:
Initial testing on one product appeared to work, so I'm going to see if I can combine the flow so that after the product variant inventory changes, there are two check-ifs, one for each warehouse.
Question though - when the inventory is being queried, is that the total inventory for the product, or is it the total inventory for each of the product variants/sizes?
Kind regards,
Nathan
Ok so... I think one of the checks above is checking product inventory of a size/variant level, not the overall stock for the product.
Example:
An order was placed for a long sleeve shirt in red. The order was for a medium size. The flow triggered as there is no stock for the large.
Is there to check both the location and Product.totalInventory?
Thanks again,
Nathan
product.totalInventory is the total across variants and locations. Not clear what total you want.
What I'm hoping to achieve is have an email sent when a product is fully sold out of all sizes in a particular warehouse only.
Is there a product.totalInventory equivalent for specific location? I use product.totalInventory in another flow to let me know when a product is sold out in all warehouses and that works well.
My current flow above sends emails whenever a specific size sells out, or detects that a size was sold out. I need it to only send the email when the product is sold out of all sizes, not just one.
Is that possible?
Kind regards,
Nathan
No, that field doesn't exist. You could need to check the quantity per variant / location and then total them up. You could do that in Run code by looping over the inventory levels for the variants.
Thanks @paul_n.
I'll have a hunt around the forum to see if I can find an example of that. If you know of any and can point me in that direction, that would be awesome too.
Thanks for all your help! 🙂
This one is kind of close. Same idea but different variables:
https://github.com/Shopify/flow-code-examples/blob/main/run-code-examples/order-sum-products/index.j...
export default function main(input) {
// Make sure that the data you return matches the
// shape & types defined in the output schema.
var inventory_product = 0;
var inventory_this_variant = 0;
input.product.variants.forEach(variant => {
const amount = variant.inventoryItem.inventoryLevels.find(level => level.location.name == "YOUR LOCATION NAME").available;
inventory_product += amount;
if(variant.id == input.productVariant.id) {
inventory_this_variant += amount;
}
});
return {
inventoryProduct: inventory_product,
inventoryVariant: inventory_this_variant
}
}
Input
query{
productVariant {
id
}
product {
variants {
id
inventoryItem {
inventoryLevels {
available
location {
name
}
}
}
}
}
}
Output
"The output of Run Code"
type Output {
"The message returned by the script"
inventoryProduct: Int!
inventoryVariant: Int!
}
Hi @paul_n,
Thanks for the above. I haven't yet had the chance to test this yet, but will be in touch when I get the time 🙂
Kind regards,
Nathan
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025