Shopify Flow Archived Items = 0 Quantity

Solved

Shopify Flow Archived Items = 0 Quantity

CrossVintage
New Member
14 0 0

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

Archive .pngArchive 0.png

Accepted Solution (1)
paul_n
Shopify Staff
1584 172 366

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 }}"
      }
    ]
  }
}

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 10 (10)

paul_n
Shopify Staff
1584 172 366

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 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
CrossVintage
New Member
14 0 0

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.

Archive .pngArchive 0.png

paul_n
Shopify Staff
1584 172 366

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

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
CrossVintage
New Member
14 0 0

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.

updated.png

paul_n
Shopify Staff
1584 172 366

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. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
CrossVintage
New Member
14 0 0

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. 

paul_n
Shopify Staff
1584 172 366

{% 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

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
CrossVintage
New Member
14 0 0

Thanks for the quick replies Paul! So I have added the code but I can only assume incorrectly as it is not working. Updated Code.png

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

paul_n
Shopify Staff
1584 172 366

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 }}"
      }
    ]
  }
}

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
CrossVintage
New Member
14 0 0

Thank you so much, it is working now! Appreciate the help 🙂