Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi,
I have a question about how to obtain a list of location IDs in Shopify Flow. I want to update inventory quantities based on specific conditions. Since I have six locations and may have more in the future, obtaining a list of all location IDs would be the best solution. However, I haven't been able to find a useful variable to obtain the location ID list in Shopify Flow.
Thanks for your help.
Solved! Go to the solution
This is an accepted solution.
Thanks, knowing the trigger helps because sometimes they have a specific variant. In this case it doesn't. This is how I would output the ID for the REST API.
{% for variants_item in product.variants %}
{% for inventoryLevels_item in variants_item.inventoryItem.inventoryLevels %}
{{inventoryLevels_item.location.legacyResourceId}}
{% endfor %}
{% endfor %}
That said, I'm not sure how you will do this for multiple inventory updates in one API call and this loop won't generate multiple API calls for you. See https://community.shopify.com/c/shopify-discussions/bulk-update-item-inventory-through-api/td-p/1507...
You could click the location in the Admin / Settings / Locations and look at the URL. You could also instead use the location name in Flow.
Personally, I would use Shopify's GraphiQL app. You can use a query like this:
{
locations(first:20, includeLegacy:true) {
edges {
node {
name
id
legacyResourceId
}
}
}
}
Thank you Paul_n
My question is like this, is there a useful variable for getting the locations in flow ?
{% for variants_item in product.variants %}
{
"location_id":828XXXXXXX, // I don't want to use hard coding here, and the locations will increase in future.
"inventory_item_id:{{variants_item.inventoryItem.variant.inventoryItem.legacyResourceId}},
"available":0
}
{% endfor %}
Thanks for your help.
Please don't do that code. You have a circular reference in it (variants.inventoryItem.variant.inventoryItem).
What trigger are you using?
trigger is : Product status updated
condition is : old status = 'ACTIVE' & product.status = 'DRAFT'
action: update the product inventory quantity = 0 in all locations
{% for variants_item in product.variants %}
{"location_id":828XXXXXXX,"inventory_item_id":
{{variants_item.inventoryItem.variant.inventoryItem.legacyResourceId}}
,"available":0}
{% endfor %}
This is an accepted solution.
Thanks, knowing the trigger helps because sometimes they have a specific variant. In this case it doesn't. This is how I would output the ID for the REST API.
{% for variants_item in product.variants %}
{% for inventoryLevels_item in variants_item.inventoryItem.inventoryLevels %}
{{inventoryLevels_item.location.legacyResourceId}}
{% endfor %}
{% endfor %}
That said, I'm not sure how you will do this for multiple inventory updates in one API call and this loop won't generate multiple API calls for you. See https://community.shopify.com/c/shopify-discussions/bulk-update-item-inventory-through-api/td-p/1507...
Thank you very much. I understand that it is not possible to make multiple API calls.
I'm not sure how you will do this for multiple inventory updates in one API call and this loop won't generate multiple API calls for you. See https://community.shopify.com/c/shopify-discussions/bulk-update-item-inventory-through-api/td-p/1507...
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By 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, 2024