A Shopify Plus user is trying to create a Flow that sends email notifications when a product sells out completely at a specific warehouse (AU or NZ), but is receiving duplicate emails for both warehouses.
Initial Problem:
The Flow triggers on ‘Product variant inventory quantity changed’
Condition checks were returning true for both warehouses because location names and inventory values for all warehouses appear in arrays
Separate flows for each warehouse still resulted in multiple emails
Solution Development:
Paul_n identified that the condition logic needed to check both location name AND inventory quantity at the same nesting level within the inventory item array, rather than checking them independently.
Current Challenge:
The user wants emails only when ALL sizes/variants are sold out at a specific location, not when individual sizes sell out. However, there’s no built-in field for total inventory per location (only product.totalInventory which spans all locations).
Proposed Workaround:
Paul_n provided a custom code solution using the Run Code action that:
Loops through all product variants
Sums inventory levels for a specific location
Returns total inventory for both the product and specific variant at that location
The user hasn’t yet tested the code solution.
Summarized with AI on October 31.
AI used: claude-sonnet-4-5-20250929.
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.
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.
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
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”
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.
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?
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.
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.
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.