Item variations returned despite filtering by location id

I am using the Node SDK and utilising the catalog API.

I have added a new “Online” location and marked some products and some variations to be available at this new online location.

When using the catalog search request to filter by location ID the primary items returned are correctly filtered however variations within that item are returned despite not being available at the online location.

This is the call I am making using the SDK

const response = await client.catalogApi.searchCatalogItems({
  enabledLocationIds: [process.env.SQUARE_ONLINE_LOCATION_ID!],
  sortOrder: "ASC",
});

I would expect to only see variations that are also available at the Online location.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Design a Catalog
Monitor Sold-out Item Variations or Modifiers
Use Item Options to Manage Item Variations

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The behavior you’re seeing is expected. When you use the enabledLocationIds filter in the searchCatalogItems endpoint, it returns CatalogItems that are enabled for the specified location. However, this does not filter out the item variations within those items that are not available at the specified location.

The enabledLocationIds filter applies at the item level, not at the item variation level. So, if an item is enabled for a location, all its variations will be included in the response, regardless of whether the variations themselves are enabled for that location.

If you need to filter out item variations that are not available at a specific location, you would need to do this filtering in your application after you receive the response from the searchCatalogItems endpoint. You can check the itemData.locationOverrides field for each item variation to determine if it’s available at the specific location.

This answer was reviewed by @Bryan-Square.

Thanks for the response, Can I ask though what is the point in being able to set a location on item variations when we can use the SDK to filter that?

Your own UI when filtering by location will remove the item variations not at that location.

Just to me seems a little pointless that the item variations can’t be filtered.