Is there a way to adjust variant quantity to a certain value directly using graphql ?

Allonsy
New Member
1 0 0

I am looking at using inventoryBulkAdjustQuantityAtLocation, but inventoryItemAdjustments only provides a availableDelta field to change quantity, so if I want to update inventory to zero, I have to query for the value first, and this waste the limit points that I dont have enough. So can I directly set quantity of a variant to zero with one request?

0 Likes
syf_
Shopify Staff
Shopify Staff
49 9 9

Hi @Allonsy,

I believe that setting the quantity of a single variant can be achieved with the inventoryActivate mutation. Sample below

 

mutation inventoryActivate($inventoryItemId: ID!, $locationId: ID!) {
  inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: 0) {
    inventoryLevel {
      id
      available
    }
    userErrors {
      field
      message
    }
  }
}

 

Hopefully this helps you achieve what you're looking to do.

Best,
Seth.

syf_ | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes