Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hey, I am trying to set up the following but struggling with the API Request part.
I want...
Product Status Change > Old Status is Active > Quantity goes from 1 to 0
Some help on the last part would be great.
Thanks
Solved! Go to the solution
This is an accepted solution.
You have a "-1" right after changes, which isn't valid JSON. I think you want that value after "delta".
Also, generally if you aren't setting a variable and it's not required, you should remove it.
{
"input": {
"reason": "correction",
"name": "available",
"changes": [
{
"delta": -1,
"inventoryItemId": "{% assign v = product.variants | first %}{{ v.inventoryItem.id }}",
"locationId": "{% assign location_inventory = v.inventoryItem.inventoryLevels | first %}{{ location_inventory.location.id }}"
}
]
}
}
You are trying to set the quantity? There are at least a couple mutations that might work, including https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/inventoryAdjustQuantities or https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productVariantsBulkUpdate
I have tried this. However, I am unsure what I need to fill out to make it run properly. I have looked through the documents to help but still no luck.
I won't be able to fill that out for you as you need to make decisions about what you are setting, etc. If you have a specific question once you try it, we might be able to help
Sorry I thought I sent the updated version. This is as far as I got, but I couldn't work out what the rest of it needed. I just done the required ones.
I would like it to deduct 1 in quanity.
The doc link above gives more details on each of these fields. Some are optional, some required.
You'll need inventoryItemId and locationId. Those both come from the variant. Since you are using a product trigger, and a product has 1 or more variants, you need to figure out which variant inventory you want to change.
Thanks. I sell vintage items only so I only have 1 of each item and I sell from only one location. Is there a way to get inventoryitemid and locationid still?
I would like all items that are live and made archived items to have there quantity reduced to 0. This applies to everything, no variants etc.
{% assign v = product.variants | first %}
{{ v.inventoryItem.id }}
Regarding location_id, do you have 1 location or many? If just one, you could do:
{% assign location_inventory = v.inventoryItem.inventoryLevels | first %}
{{ location_inventory.location.id }}
Otherwise, you could go to the list of locations in the Admin (Settings / Location) and click on one. In the URL you will see an ID for that location.
I think you need the format like this "gid://shopify/Location/35317088278" substituting your own ID
Thanks for the quick replies Paul! So I have added the code but I can only assume incorrectly as it is not working.
The code is as follows:
{
"input": {
"reason": "correction",
"name": "available",
"referenceDocumentUri": "",
"changes": [-1
{
"delta": 0,
"inventoryItemId": "{% assign v = product.variants | first %}
{{ v.inventoryItem.id }}",
"locationId": "{% assign location_inventory = v.inventoryItem.inventoryLevels | first %}
{{ location_inventory.location.id }}",
"ledgerDocumentUri": ""
}
]
}
}
Thanks
This is an accepted solution.
You have a "-1" right after changes, which isn't valid JSON. I think you want that value after "delta".
Also, generally if you aren't setting a variable and it's not required, you should remove it.
{
"input": {
"reason": "correction",
"name": "available",
"changes": [
{
"delta": -1,
"inventoryItemId": "{% assign v = product.variants | first %}{{ v.inventoryItem.id }}",
"locationId": "{% assign location_inventory = v.inventoryItem.inventoryLevels | first %}{{ location_inventory.location.id }}"
}
]
}
}
Thank you so much, it is working now! Appreciate the help 🙂
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025