Re: Stock level to zero, product quantity variant update using Shopify Flow

Solved

Stock level to zero, product quantity variant update using Shopify Flow

Bekind24
Shopify Partner
10 0 1

Hello,

 

I aim to make my inventory quantity 0 (out of stock) if it reaches 10 stocks only.

 

This is to make sure we do not oversell when we drop new products.

 

I ran a flow but some of the reports were unsuccessful and I am stuck. Is it also possible that I can make the flow for only a specific product?

 

What can I do or edit to make this flow work?

 

I appreciate all the help and guidance!

 

shopify-flow-variant-quantity.png

 

Screenshot 2024-07-08 122615.png

 

This is my HTTP Request currently

 

Screenshot 2024-07-08 155330.png

Accepted Solutions (3)

lynth
Shopify Partner
107 5 14

This is an accepted solution.

First of all, you need to ask the store owner for approval for the write_inventory scope. Currently, you can probably only read values, and the request is being blocked.

Regarding triggering it on a specific product, I think you can only trigger the flow when a product is added or its quantity changes. Even if you could use a webhook to trigger it, it would be triggered every time the product status changes.

So, use your implementation but add a filter inside the flow to run only if the product handle or ID matches the selected product.


If you need further assistance or additional changes, feel free to ask!

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

View solution in original post

Sonya_2025
Shopify Partner
254 33 48

This is an accepted solution.

At your check permission page. Click edit button, tick up the inventory permissions here

Sonya_2025_0-1720429286276.png

 

And if you want to set this flow to particular product. Put a tag on the products. And then you can add a condition  in the flow, if the product has the tag, then go to the set inventory action.

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out. EMAIL ME  
Motivate me by  PAY ME

View solution in original post

lynth
Shopify Partner
107 5 14

This is an accepted solution.

Use your implementation, but add if statements for specific products before it. Then, you can use a dynamic variable for the product/variant ID reference e.g. {{productVariant.id}}. Try different ways and pick the best one.

Example:

lynth_0-1720431377405.png

If you still need assistance, feel free to ask! Please check my answer as a solution if I helped you.

 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

View solution in original post

Replies 17 (17)

Sonya_2025
Shopify Partner
254 33 48

Hey @Bekind24 

Do you ticked up write and read inventory permission for your custom app?

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out. EMAIL ME  
Motivate me by  PAY ME
Bekind24
Shopify Partner
10 0 1

Hello Sonya!

 

Thank you for the reply! 🙂

 

These are the ones I ticked. What are the other things I am missing to tick?

 

I am not an expert in this and only followed some guidance in the community as well.

 

Screenshot 2024-07-08 163916.png

lynth
Shopify Partner
107 5 14

You need write_inventory scope. You have to be the store owner not only admin. 

Here is the guide:
https://help.shopify.com/en/manual/shopify-flow/reference/actions/send-http-request

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Sonya_2025
Shopify Partner
254 33 48

This is an accepted solution.

At your check permission page. Click edit button, tick up the inventory permissions here

Sonya_2025_0-1720429286276.png

 

And if you want to set this flow to particular product. Put a tag on the products. And then you can add a condition  in the flow, if the product has the tag, then go to the set inventory action.

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out. EMAIL ME  
Motivate me by  PAY ME

lynth
Shopify Partner
107 5 14

This is an accepted solution.

First of all, you need to ask the store owner for approval for the write_inventory scope. Currently, you can probably only read values, and the request is being blocked.

Regarding triggering it on a specific product, I think you can only trigger the flow when a product is added or its quantity changes. Even if you could use a webhook to trigger it, it would be triggered every time the product status changes.

So, use your implementation but add a filter inside the flow to run only if the product handle or ID matches the selected product.


If you need further assistance or additional changes, feel free to ask!

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Bekind24
Shopify Partner
10 0 1

Hi Lynth!

 

Thank you for explaining thoroughly about the HTTP request and the trigger flow. I was able to make it work! I should just have ticked the write_inventory scope.

 

Screenshot 2024-07-08 171743.png

 

Now, I just need to figure out how should the body be written as I am going to be specific to 9 products only which will be launched tonight (since it is not ideal that other products' inventory quantity be affected).

 

How can I find the "inventory_item_id" to change it for each product? Or should I add another condition?

 

Thank you in advance!

lynth
Shopify Partner
107 5 14

This is an accepted solution.

Use your implementation, but add if statements for specific products before it. Then, you can use a dynamic variable for the product/variant ID reference e.g. {{productVariant.id}}. Try different ways and pick the best one.

Example:

lynth_0-1720431377405.png

If you still need assistance, feel free to ask! Please check my answer as a solution if I helped you.

 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Bekind24
Shopify Partner
10 0 1

Thank you for the big help Lynth!

 

This is what I have come up and hopefully, it is correct and will work 😄

 

I have added another condition (if any conditions are met) for product variant IDs

 

Screenshot 2024-07-08 215005.png

lynth
Shopify Partner
107 5 14

Great 🙂 It looks good 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
paul_n
Shopify Staff
1343 151 311

FYI, Flow now has a Send Admin API request action that handles scopes, API key, etc for you. Highly recommend using that in the future as it's way easier.

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.
Bekind24
Shopify Partner
10 0 1

That sounds awesome! I will look further into this Admin API

Maison_de_Modes
Excursionist
33 5 3

Quick question for a similar situation... I need to (trigger) detect when variant inventory is updated, then (condition) if the variant's inventory is < 3, (action) I need to update the variant's inventory to 0. 

 

I get how to do the trigger/conditional pieces in Flow. Might you be able to provide some guidance re: what the Http Request would look like? Thanks. 

paul_n
Shopify Staff
1343 151 311

I think you would use the "Send Admin API request" action and call "inventoryAdjustQuantities". Details of the inputs are here: https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/inventoryAdjustQuantities

 

One note - be careful that you don't create an infinite loop by running on inventory updated and then update inventory. You should check both the before and after quantity to prevent it from calling the action repeatedly.

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.
Maison_de_Modes
Excursionist
33 5 3

Thanks. Only variants with inventory of 1 or 2 will be set to 0. If 3 or more, no change. This'll avoid recursive updates. 

Kalen_Jordan
Shopify Partner
768 34 135

Sure you don’t want to use safety stock for this? 

Bekind24
Shopify Partner
10 0 1

I'm curious how safety stock could help us in our overselling issue. Please elaborate.

We are experiencing overselling during launch day because of simultaneous multiple checkouts from customers

Kalen_Jordan
Shopify Partner
768 34 135

There's some more info here:

https://www.shopify.com/retail/safety-stock

 

You basically set an amount (10 in your case), and it won't allow people to buy more if the inventory goes below that level.