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.

web request icon
Request
code icon
Custom Code

You're in good company

"MESA has been a game changer for us. And, if you ever get stuck, their support team is always super helpful."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
PetFriendly

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

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Zailys

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

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Rothy's

How it works

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

web request icon

Request

App connector: Web Request • 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. No manual configuration is needed - the trigger handles all incoming requests automatically.

code icon

Custom Code

App connector: Code • 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});
  }
}

Ready to set this up? It only takes 2 minutes.

Our support team will even help you personalize this workflow for free.

Get started →

Make it your own!

Customize this workflow even further:

Filter by specific locations
Modify the GraphQL query to only show inventory from certain store locations, like excluding warehouse stock and only displaying retail locations for customer pickup options.
Add low stock warnings
Extend the script to include conditional logic that flags when inventory drops below a threshold, automatically adding "Low Stock" or "Only X left" messages to your product display.
Cache results for performance
Connect to MESA's data tables to temporarily save inventory data and reduce API calls, especially useful for high-traffic products that get checked frequently throughout the day.
Send inventory alerts
Chain this workflow with email or Slack notifications to alert your team when specific products reach zero inventory at key locations, enabling faster restocking decisions.

Common questions

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

What happens if a location has zero inventory?

Can I limit which locations appear to customers?

Ready to start displaying real-time inventory levels by location on your product pages?

7-day free trial • 2 min setup • Cancel anytime

Need help? Our automation experts will help you personalize this workflow for free. Contact support