"On Hand" Inventory Quantities

Topic summary

A user needed to retrieve “On Hand” inventory quantities (rather than “Available”) in Shopify Flow for daily inventory email reports. The challenge arose because Flow’s default data fetching doesn’t support the “On Hand” field—it requires a special API field type that Flow cannot access directly.

Workaround Solution:

  • Use Flow’s “Send HTTP request” action to call the Shopify API directly
  • Retrieve the “On Hand” quantity via a GraphQL query
  • Use the “Run code” action to process the response
  • Write the result to a product metafield for later use

Key Technical Detail:
About 20 fields out of thousands in Shopify’s API require manual user input that Flow doesn’t natively support. The “On Hand” quantity is one of these edge cases.

Outcome:
The workaround successfully enabled updating order printer templates to hide line items with zero on-hand inventory. The solution demonstrates Flow’s capability to write to metafields for extended functionality.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

Hello,

I am using Shopify Flow to send a daily email to summarize the inventory quantities for certain products across our locations. The flow has a scheduled time trigger and then gets the order data for products with a certain tag. In the internal email, I am having trouble figuring out the syntax to get the “On Hand” inventory quantity for an inventory level. Right now I am getting the “Available” quantity and putting it in a HTML table by doing the following:

{% for product in getProductData %}> {% for variant in product.variants %}> > {{product.title}} {{ variant.sku }} > > {% for inventoryLevel in variant.inventoryItem.inventoryLevels %}> {{ inventoryLevel.available }} > {% endfor %}

How do I get the “On Hand” quantity instead of the “Available”?

Thanks,

Jonathan

You cannot get the “on hand” quantity in Flow yet. The issue is that “on hand” is accessed via a special type of field in the API that Flow does not yet support.

1 Like

Im having so much trouble understanding why something so simple isnt available to users. this is a basic need to pick and pack. has there been any work arounds ?

Yes, you can call the API directly using Send HTTP request to retrieve the field. Example request for another field:

{
"query": "query ProductCollection($collectionID:ID!, $productID: ID!) { product(id: $productID) { id\n inCollection(id: $collectionID) } }",
 "variables": {
    "productID": "{{ product.id }}",
    "collectionID": "gid://shopify/Collection/626830573590"  
  }
}

As the reason, Flow fetches a lot of data by default for you. A few fields actually require user input (including this one). The problem is that Flow doesn’t have a way to allow that user input. It has to be built manually for each field. Fortunately, of the thousands of fields, there are only about about 20 or so like that.

1 Like

Thanks so much I was finally able to do it! after like 5 hrs… basically, after getting the Send HTTP Request functioning I was able to do the runcode action then update product meta field.

This allowed me to write the On Hand Qty to the meta field. Now I can modify my order printer template to hide line items that have 0 on hand! being able to use flow to write to meta fields is very useful.

Thanks Paul_n im new to shopify and coding and this helped a ton

1 Like

Awesome, nice work. Feel free to share that query back here for others to use.