Re: Issues with variant stock information in Flow

Issues with variant stock information in Flow

woolkind
Excursionist
31 0 6

I have created a flow that I want to use to tag an order depending on the stock level of the variant at the time of the order. We allow customers to order when we have no stock but I want the order to be tagged so that we know if the item is in stock or requires to be made. 

 

I have set up the flow but I just had an order and it tagged the order incorrectly. 

 

Im not sure how to troubleshoot this but if someone can help that would be great.

 

Attached is a screenshot of the flow for info.

 

woolkind_0-1741881834731.png

 

Replies 10 (10)

Bob_
Pathfinder
82 13 15

Can't test it as we don't sell out of stock but this should be closer to what you need as your not telling the flow to check every item in the order:-

 

Bob__0-1741956504782.png

 

.
woolkind
Excursionist
31 0 6

thanks Bob,

 

will give this a try but within the step there is a “for each line item” option selected. But maybe it does  something else 

woolkind
Excursionist
31 0 6

Tried this and retried my original run with 1 item in stock and both had the same result.

 

I think the flow is running after the inventory has been taken from the shop and thats what the issue is

paul_n
Shopify Staff
1774 194 415

Open the workflow run where it didn't do what you expected. Look at the condition especially. What do you see?

Paul_N | Flow Product 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.
woolkind
Excursionist
31 0 6

It looks like it sees the inventory stock at 0 for the item when it should have been 1. Could it be that its checking the stock after the order goes through?

 

Do I need to check the on hand stock instead?

paul_n
Shopify Staff
1774 194 415

It runs after an order is created. I'd expect that part of an order being created it removing the stock from the store, so that the next order see's a more accurate count. 

Paul_N | Flow Product 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.
woolkind
Excursionist
31 0 6

Yeah it's after the order is created. So ive adjusted the calculation to trigger when stock drops below 0 of any item on the order. Hopefully that picks it up.

 

Thanks.

km1984_ph
Shopify Partner
2 0 0

Did adjusting when the calculation triggers help this work for you? Can you please explain how/where you made that adjustment if it did work?

 

Our store is running into a similar issue, where we want to confirm that there is enough available inventory to cover the ordered quantity of each line item. As you found, it's clear that stock is being checked after the necessary quantity has been allocated for the order, which is not particularly helpful in this situation.

 

This is what our condition looks like – it's using product instead of variant, but I think we're essentially looking for the same kind of result:

Screen Shot 2025-04-03 at 10.28.04 AM.png

I had the idea to add the quantities for each of those variables (lineItems_item.quantity and lineItems_item.product.totalInventory) and then compare that to lineItems_item.quantity – if the sum of the two is greater than or equal to the value of lineItems_item.quantity then inventory at the time of the order should have been adequate – but I'm pretty sure that would require javascript in a Run Code action, which is a bit beyond my abilities.

 

Thanks!

woolkind
Excursionist
31 0 6
Yes I managed to get it to work by basically doing the test after the sale. So if the stock amounts fell below 0 then I knew I needed to make things and could add then add the correct tag.


Hope that helps
km1984_ph
Shopify Partner
2 0 0

Ah, got it. Unfortunately I don't know if that will help with our situation, but I appreciate the info nonetheless. Maybe I can adapt the idea to the issue we're trying to work around.

 

Thanks!