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:
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:
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.