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
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 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
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
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 ![]()