Sales channel - Get inventory from a specific location

Hi, we have a sales channel with permission read_product_listings to access products published to the sales channel. We want to read the inventory of a specific location.

We access their products using the REST API endpoint …/product_listings.json and this data does not contain the product inventory per location.

How can we retrieve the product inventory from our sales channel of a specific location?

Note that:

  1. We cannot query products with the permission that we have
  2. The product listing webhooks do not contain the necessary information
  3. The user cannot assign the location to the sales channel
  4. If we request access to read_products we then have access to all their products (and not the one assigned to the sales channel only).

Thank you

1 Like

Hey @Francois_Rulliere, currently you will need to increase your scopes to get that location specific information.

Can you share your business case for needing this? I would be happy to explore other routes to get close without needing excessive scopes.

I should also note that the REST api’s are legacy now with some product API’s deprecated in REST, so all new improvements and changes to them will be in Graphql.

Our use case: a merchant want to sell to our sales channel, however their items are in different locations and only one can do international shipping. Hence, they want to select this specific location as the sale channel inventory.

So ok we can increase the scope, do we need the full read_products scope? Or is there a narrower scope that only include the inventory of the product listings?

We would be happy to use the GraphQl API instead of GET …/product_listings.json but there is no equivalent in REST (as far as I know). The doc tells us to use the query products but it needs the read_productsscope which includes all products (not products shared to the sales channel).

Have you considered using the storefront API? For your use case of showing only products available from a specific international location, you can use the Storefront API with buyer context instead of trying to filter inventory manually.

The Storefront API’s @inContext directive filters products by market. Here’s an example query you could use that works with tokenless access so you wouldn’t need any additional scopes:

query internationalProducts @inContext(country: FR) {
  products(first: 10) {
    edges {
      node {
        title
        availableForSale
      }
    }
  }
}

Then when creating carts, set the buyer identity. This will ensure that the merchants fulfillment and shipping rules will be applied at checkout, blocking any products that may not be available to ship to that customer:

mutation {
  cartCreate(input: {
    buyerIdentity: {
      countryCode: FR
    }
    lines: [...]
  }) {
    cart {
      checkoutUrl
    }
  }
}

In addition to this, we are improving the experience here with Fulfillable Inventory which will enable storefront filtering to automatically mark products as “out of stock” if there’s no inventory at locations configured to fulfill to that shipping zone. This will help so buyers won’t need to go to checkout to find that a product is out of stock for them.

Thank you, we did not consider the storefront API, I will look into it.

Your solution works only if the location is associated with a market. However for us the location can be a specific warehouse, or an artificial location to allocate the stock.

If you don’t have other APIs or endpoint, we’ll request the user to give us more scopes (using read_products) and get the product inventory from the products API.

In this case if you need that specific access, additional scopes are the way to go.

Are you using Shopify managed app installs to make these changes easier?

We use the “standard” way that was there before “managed apps” was created.

To my understanding we will need to upgrade our code, and ask the merchant to access our app to request new access scopes.

Is it still the case or is there a better way?

Yes, merchant will need to access your app to approve all app scope changes.

The reason I mentioned managed access is this simplifies the process as you only need to update your app configuration file and the access is requested automatically when the merchant opens your app, as opposed to having to do this individually for each merchant.

Got it.

It’s fine, we prefer to have the minimal permissions so only users interested in this feature will upgrade their apap.

Thank you