Flow - Cancel Order if negative inventory at 1 location

Topic summary

Cancel orders automatically when any single location’s inventory goes negative in a two-location (US/Canada) setup. Shopify Markets’ IP-based segmentation occasionally allows cross-border orders, pushing one location’s stock below zero.

Initial Flow attempt only evaluated total inventory across all locations, missing cases where one location is negative but the sum remains positive.

Requested solution: a per-location check on line items that triggers order cancellation if any location’s availability is < 0, plus step-by-step guidance.

Update/workaround: Use a deprecated field in Flow conditions to evaluate each location individually: order.lineItems.variant.inventoryItem.inventoryLevels.available (the available attribute appears under deprecated fields). This checks each stocked location and allows a < 0 test, then proceed to cancel the order.

Notes: Shopify indicates recent API changes and ongoing work to improve Flow support for this scenario.

Status: No confirmation of implementation success; guidance provided but final resolution pending. Screenshots illustrate the Flow and field selection; the deprecated field is central to the workaround.

Summarized with AI on January 2. AI used: gpt-5.

Hi everyone,

Hope you’re well !

I am running a shop in US and Canada with 2 inventory locations (1 per country). I am using Shopify Markets to prevent people from the US to see Canada inventory and vice versa.

However, sometimes (I imagine because the market detection is IP based), it does not work well and some US folks are able to complete orders even though the US inventory is at 0. When this happens, the inventory at the US count goes below zero (or even further if it was already sitting at -1).

So I thought I would use Shopify flow as a second level barrier to automatically cancel any order that generates negative inventory level at any location taken individually on any of its line item.

I came up with this flow

However, this is not working well, as it only triggers if the sum of the inventory count at all location is negative. For example, if an order is placed, and it takes Product XYZ US inventory to -2 but Canada inventory still has 10 units of Product XYZ, it does not trigger because the Flow considers that the inventory level is still positive as it counts 8 units (sum of Canada + US).

I think there is a way to get Flow to make the check on a per-location basis, but my experience with Flow is limited, so I could not figure out how…

(I thought about modifying the default Tag out of stock products for a single location only template and inserting a GetData to grab the last 1 order within the last 1 minute and cancel, but I could not figure that either… That seemed even more complicated)

Any help would be greatly appreciated

Thanks for your answer, it would be great if you could just walk me through the steps here… As they say: Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime… Especially since the answer might help others too… Unless you are pitching a sale (even if that were the case, showing your skills on this specific matter might be good marketing for you!)

Hi @nguetto2 ,

There’s been some API changes in this space lately that we’re working on supporting better in Flow, but for now there is a deprecated field that might give you what you’re looking for.

Looking at the order.lineItems.variant.inventoryItem.inventoryLevels.available field (available will be in the deprecated fields at the bottom) will check each location that stocks the product and check if it is < 0.

Hope that helps!