Show Store Inventory Levels by Location on Shopify Product Pages

Show Inventory Levels By Location On Your Product Page

2 min setup

No coding required

Runs automatically

Display real-time inventory counts from each warehouse or retail location directly on your Shopify product pages. This workflow pulls current stock levels from your connected locations and presents them in a clear format, letting shoppers see exactly where items are available. The location-specific inventory data updates as stock levels change, giving customers accurate availability information before they purchase. Please note, this template runs each time the product page is loaded so we recommend the Unlimited plan.

How it works

2 steps to start displaying real-time inventory levels by location on your product pages

Request

App connector: [Web Request](/content/apps/webrequest/integrate "View Web Request integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: This web request trigger captures the variant ID from your product page when customers want to see inventory levels, starting the entire lookup process.

When someone visits your product page and the inventory check runs, this step receives the variant ID through a query parameter in the URL. The trigger is automatically configured to accept web requests and includes CORS headers to allow cross-origin requests from your storefront. It captures the variant_id from the query string and passes this essential identifier to the next step for inventory lookup.

Query Inventory by Location

App connector: [Code](/content/apps/custom/integrate "View Code integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: This JavaScript code connects to Shopify's GraphQL API to fetch exact inventory quantities for each location where your product variant is stocked.

The custom code takes the variant ID from the previous step and builds a GraphQL query to retrieve inventory levels across all locations. It specifically looks up the product variant, gets its inventory item, and returns the available quantities for each location name. The script uses MESA's built-in Shopify GraphQL connection, so authentication is handled automatically. The response includes location names paired with their available inventory counts, which gets returned as structured JSON data for your frontend to display.

const Mesa = require('vendor/Mesa.js');
const ShopifyGraphql = require('vendor/ShopifyGraphql.js');

/**
 * A Mesa Script exports a class with a script() method.
 */
module.exports = new class {
  script = (payload, context) => {
    let vars = context.steps;
    let variantId = vars.webrequest.querystring.variant_id;

let query = `
      {
        productVariant(id:"gid://shopify/ProductVariant/${variantId}") {
          sku
          inventoryItem {
            inventoryLevels(first:10) {
              nodes {
                location {
                  name
                }
                quantities(names:"available") {
                  available: quantity
                }
              }
            }
          }
        }
      }
    `;

const r = ShopifyGraphql.send(query, null);

Mesa.output.next({"response": r.data.productVariant.inventoryItem.inventoryLevels.nodes});
  }
}

Frequently asked questions

Does this work with products that have multiple variants like size and color?

Yes, the workflow looks up inventory for the specific variant ID passed in the request, so each size/color combination will show its own accurate inventory levels across your locations.

What happens if a location has zero inventory?

The GraphQL query will still return that location with a quantity of 0, so you can choose to either display "Out of stock" or hide those locations entirely in your frontend code.

Can I limit which locations appear to customers?

The current workflow shows all locations where the product is tracked, but you can modify the GraphQL query to filter by specific location IDs if you want to exclude warehouses or staff-only locations from customer view.

Make this template your own!

Customize this workflow even further:

Avg. App Store rating 4.9/5 Merchant reviews 157

You're in good company

PetFriendly

"It's like Zapier but exactly designed for Shopify. I have been able to complete all the workflows that I've needed."

Zailys

"The MESA team has been amazing at helping us set up our automations. We would highly recommend this app!"

Rothy's