Solved

Flow - Cancel Order if negative inventory at 1 location

nguetto2
Visitor
2 0 0

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

 

Shopify Flow Cancel Order.JPG

 

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 

 

Accepted Solution (1)

DaveMcV
Shopify Staff
87 27 24

This is an accepted solution.

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. 

 

DaveMcV_0-1711593305613.png

 

Hope that helps!

 

DaveMcV | Flow Development 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 2 (2)
nguetto2
Visitor
2 0 0

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!)

DaveMcV
Shopify Staff
87 27 24

This is an accepted solution.

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. 

 

DaveMcV_0-1711593305613.png

 

Hope that helps!

 

DaveMcV | Flow Development 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.