Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi,
Is there any way to update the quantity of specific products using Shopify Flow? not looking to use any 3rd part apps.
e.g. Trigger happened >> set the quantity for a specific product to 100.
I don't want to hide/unhide the product, I just want to auto-update the inventory.
is it possible by using flow, I searched on all templates and couldn't find one.
Thanks
Solved! Go to the solution
This is an accepted solution.
Thanks, Lily for your help, although it wasn't exactly what I was looking for, it did lead me in the right direction and I was able to find a solution that worked for me. I appreciate your assistance.
In case anyone looking for the same thing here is what worked for me:
use Post instead of Put, and use this URL to set the inventory level:
https://your-development-store.myshopify.com/admin/api/2023-01/inventory_levels/set.json
Body:
{"location_id": 213334567,"inventory_item_id": 12345467789,"available":33}
Hi,
We do not have a Flow action to do that yet. However, if you have some technical skills, you could do that now by calling the Shopify admin API to update the product inventory. We don't have any plans yet to add this action short-term, but we've made a note that you are looking for it.
Hope this helps.
Lily
To learn more visit the Shopify Help Center or the Community Blog.
BTW, in order to help prioritization of this request, I suggest that you add a request a merchant frustration from shopify support.
To learn more visit the Shopify Help Center or the Community Blog.
Thanks, Lily,
Do you mean using shopify admin API + Shopify Folw? or this could be done usnig Shopify Admin API alone?
would appreciate it if you could share some more example in what I should connect Shopify Admin API to?
Thanks
Yes, I do mean to use Shopify admin API + Shopify Flow.
BTW, the previous link I gave you is GraphQL API, which I don't think can easily used by you. Instead, you should use the REST API . The API has details on the header you need as well in the example:
```
curl -d '{"variant":{"id":808950810,"metafields":[{"key":"new","value":"newvalue","type":"single_line_text_field","namespace":"global"}]}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2022-10/variants/808950810.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
```
In order to get an `access_token`, you could follow this instruction.
You could use the `Send HTTP Request` action in Flow. So, the flow would look something like this:
To learn more visit the Shopify Help Center or the Community Blog.
Thank you, Lily, for your helpful insight and support. I am still encountering below error, even after changing "newvalue" to "100" as the desired quantity setting and attempting to leave "newvalue" as is, still get the same error.
This is an accepted solution.
Thanks, Lily for your help, although it wasn't exactly what I was looking for, it did lead me in the right direction and I was able to find a solution that worked for me. I appreciate your assistance.
In case anyone looking for the same thing here is what worked for me:
use Post instead of Put, and use this URL to set the inventory level:
https://your-development-store.myshopify.com/admin/api/2023-01/inventory_levels/set.json
Body:
{"location_id": 213334567,"inventory_item_id": 12345467789,"available":33}
Nice! Though I was no expert on the admin API, I was happy to have helped. 🙂
To learn more visit the Shopify Help Center or the Community Blog.
Thanks buddy, this helped so much!! Just want to add some additional info for other noobs like me! 🙂
To get API Access Token I followed this: https://mixedanalytics.com/knowledge-base/get-your-shopify-access-token/
Location Id: Go to Shopify Settings and select the location, you can find the location ID in the URL.
Inventory Item ID: I used {{productVariant.inventoryItem.legacyResourceId}}
Available: Input number for desired inventory amount to insert.
For me it looked something like this (I wanted to set quantity to 0 based on my conditions):
{"location_id": 213334567,"inventory_item_id": {{productVariant.inventoryItem.legacyResourceId}},"available": 0}
Bonus Tip: I setup an internal email action at the end to also notify me every time the flow automation set a product inventory to 0.
Hello Mussty,
For example can you set a rule when the stocklevel is 2 you let shopify flow edit it to 0?
I would like that or do you not have something like this?
Kind regards
Stan Legebeke
Hi Stan, I have done exactly this, for me when stock level reaches 3 or less I overide stock level to 0 with shopify flow using the method above. I cant open flow on my phone with full view, I will reply tomorrow with a screenshot from my laptop on how how I did it.
Thankyou, that is exactly what I am looking for.
Thanks in advance.
Hi Stan, no worries at all!
Here is how my flow automation is set up: I will probably remove the email at the end as it gets annoying. I set it up just to see if it was working as intended.
Send HTTP Request setup:
Email Setup:
If you follow the rest it should be easy to set up.
Thanks a lot, I will implement it and hope it reduces a lot of issues when product stock is low.
Hello Mussty,
I have been working on this for a few days, but can't seem to get it to work. I want to create a flow that adjusts the inventory of an item once monthly, when I run the flow it get
{"errors":"Not Found"}
Same thing when I follow the link itself. Not sure what is wrong, I believe I followed everything mentioned in the thread. Were there any other steps you took?
Bit of a noob, appreciate any help!
You are getting that on the Send HTTP Request? I think it would help to see your configuration but my first guess is that you are using the wrong ID to set inventory.
Hi Paul, yes that's right. Attaching the configuration and exact error below.
{"status":404,"response_body":"{\"errors\":\"Not Found\"}","verb":"POST","url":"https://your-store.myshopify.com/admin/api/2023-01/inventory_levels/set.json","request_body":"{\"location_id\": xyz,\"inventory_item_id\": xyz,\"available\":5}\n\n"}
Thanks in Advance!
Are you sure the ID's match? Probably doesn't matter but remove any whitespace after the string, since I see 2 newlines. Is neither of those work, try it with postman or some API client to get it working.
Hi Paul, when you are referring to ID do you mean Store ID, inventory ID, or Location ID? I have a feeling that the URL is the problem as its giving a 404 and I was actually able to accidentally access the login page of other stores with the same API. I have checked the Store ID several times to ensure it is accurate.
Hi!
Really appreciate the help I got here!
BBPT I was stuck on with the same 404 error and you might have the same issue.
Note that the "inventory_item_id" is not the same value as the variant ID you can pick up on the product/variant page link.
I used Matrixify to retrieve the variables I needed but you can also get via API.
You can use /adjust to add or subtract a quantity instead of setting a value.
Hope this helps!
Adding my experience to this thread since it was beneficial in getting to the solution I created. What was unique about my problem was I needed to iterate through every product and use metafield variables in my POST request. In my company's situation our PIM syncs daily but can only house the stock levels in a metafield. So in my metafield with key=web_enabled_inventory that is the most accurate stock level as opposed to Shopify's that reduces/increases with orders & returns. So I need to overwrite all stock levels daily with the metafield value.
Above is my workflow in Shopify Flow with the {store name} crossed out. You would enter your store's name there. Above in this thread does a great job already of detailing how to get Access Tokens and such. This comment here keeps it concise. The only piece missing now is below, the body of my HTTP request with some varibles you would replace bolded:
{% for metafields_item in productsForeachitem.metafields %}{% if metafields_item.key == 'web_available_inventory' %}{% for variants_item in productsForeachitem.variants %}{"location_id": [your location_id here],"inventory_item_id": {{variants_item.inventoryItem.id | split: "/" | last}},"available":{{metafields_item.value}}}{% endfor %}{% endif %}{% endfor %}
Hope this information helps anyone else looking to utilize Shopify Flow for inventory level automation!
Hello, I followed the steps you had here except that I removed the last 2 steps, which are the notifications. I aim to make the inventory quantity equal to 0 when it reaches 10 only. I don't know if the flow works because it says like this:
We are going to have a new launch of products and we want to make sure that we don't oversell, hence we make the flow.
Does this mean the flow I created doesn't work because it says "The request was unsuccessful" and the condition is true?
There are successful reports though, here is the sample of succeeded runs that I got:
Thank you so much! Big help!
If you are calling the Shopify API, use the new action, "Send Admin API Request". It's way easier and handles the API key for you.
That error looks like whatever API key you are using does not have the correct permissions for that mutation. You can adjust that in the Admin
Hi Paul_n
Perhaps you could assist. I am trying to adjust inventory quantities in select locations on select orders when they are created, adding an increment of 1 for each item within the order (a workaround for limited inter-location transfer functionality and staff permissions), which fits in with this discussion.
So the flow is set up to Get Order Data, and then loop for each item. The HTTP request body is:
{"location_id":154example,"inventory_item_id":{{lineItemsForeachitem.id}},"available_adjustment":1}
However I am receiving this error:
Is this type of request possible? Any advice would be appreciated.
Thanks
That id you are putting in inventory_item_id is not an iventory_item_id but an order_id. Also, your comma is inside the double-quote rather than outside it. This should read like {"location_id":154example", and NOT {"location_id":154example,"
Not sure of your use case here, but if you need to update each inventory item in the order, you will need to loop over the lineItems and their inventory items in the action using liquid to build the list of items you want to update.
I'd recommend using Send Admin API request instead and call the inventoryAdjustQuantities mutation, which allows setting multiple quantities at once and should be easier to use than Send HTTP Request. See https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/inventoryAdjustQuantities
Please add my name to the list of people requesting this. Thanks.
This is doable now using Send Admin API request.
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024