> ## Documentation Index
> Fetch the complete documentation index at: https://product-discovery.developer.voyado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Store-specific stock numbers

> Show store-specific stock numbers for both online and physical stores.

Retailers with both online and physical store channels, so-called omnichannel retailers, frequently have a large share of visitors who use the site to explore the product range and discover items to buy, but still prefer making the actual purchase in the store. To cater to that need, Elevate supports supplying store-specific stock numbers for variants. This enables visitors to get an experience that is tailored towards their preferred physical stores.

## Supply store and stock information

Store and stock information is defined on [variants](/elevate/docs/integration/catalog-imports/format-overview#variant) in the [catalog import](/elevate/docs/integration/catalog-imports/catalog-imports). Supply the online stock information in the stock number element, `stock`, of the variant data object, and the store and store-specific stock information in the `storeStock` attribute, within the variant.

If a store is not supplied on a variant, that variant will be considered out of stock for that store, which is the same behavior as if the stock number would be set to 0. The only difference between setting a store's `storeStock` to 0 and omitting the store is that the omitted store will not be returned in the availability array on the variant, as opposed to the store being returned with stock number 0. Thus, unless stores should be displayed with stock 0, we recommend omitting the store instead of setting `storeStock` to 0, in order to save on the amount of data being sent back and forth.

## Query parameters

There are two query parameters related to store-specific stock numbers: `stores` and `channels`.

The `stores` parameter should contain the keys of the stores that the site visitor has selected, as a pipe-separated string. The stores provided are taken into account when computing the stock status of products and variants for the query. The `availability` array returned on variants shows the online stock number and the stock numbers for all the stores in the `stores` parameter, unless on a product page, where all stores are always returned.

The `channels` parameter can normally be omitted, but needs to be used if the online (default) store should be ignored. The valid values for `channels` are:

* `ONLINE` — ignores the `stores` parameter.
* `ONLINE|STORE` — uses both the online store and the provided stores.
* `STORE` — uses only the provided stores.

If `STORE` is explicitly provided (for example `STORE` or `ONLINE|STORE`), then `stores` is required and cannot be empty. Omitting `channels` is identical to `ONLINE|STORE`, except that an empty or omitted `stores` is allowed.

See [query parameters](/elevate/docs/integration/site-integration/query-integration/query-parameters#stores-and-channels) for a detailed example with a table.

## Example

The following example shows a site with stock levels online and in two physical stores identified by the store keys `240` and `100`. The site has three products, and each product has one variant. For the sake of the example, we assume these products belong to a `chainsaw` category.

### Catalog import example

The information in the [catalog import](/elevate/docs/integration/catalog-imports/catalog-imports) for those products is as follows:

```json title="Simplified example catalog import" icon="code" expandable theme={null}
{
    "replace": {
        "key": "1001",
        "productGroup": {
            "products": {
                "1001-100": {
                    ...
                    "variants": {
                        "1001-100-1": {
                            "defaults": {
                                "stock": 10,
                                ...
                                "storeStock": {
                                    "240": 5,
                                    "100": 0
                                }
                            }
                        }
                    }
                },
                "1001-200": {
                    ...
                    "variants": {
                        "1001-200-1": {
                            "defaults": {
                                "stock": 10,
                                ...
                                "storeStock": {
                                    "240": 0,
                                    "100": 0
                                }
                            }
                        }
                    }
                },
                "1001-300": {
                    ...
                    "variants": {
                        "1001-300-1": {
                            "defaults": {
                                "stock": 0,
                                ...
                                "storeStock": {
                                    "100": 1
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```

The products and their stock levels can be summarized as follows:

| **Product key** | **Online stock level** | **Store stock levels** |
| --------------- | ---------------------- | ---------------------- |
| `1001-100`      | 10                     | `240`: 5, `100`: 0     |
| `1001-200`      | 10                     | `240`: 0, `100`: 0     |
| `1001-300`      | 0                      | `100`: 1               |

### Query

A query with the search phrase `chainsaw` is made to the `search-page` endpoint. Included in the query are additional parameters to show stock levels online and from the physical store with the key `240`.

<Tabs>
  <Tab title="REST API">
    ```bash icon="terminal" theme={null}
    curl -X GET \
    'https://{cluster-id}.elevate-api.cloud/api/storefront/v3/queries/search-page?market=US&locale=en-US&customerKey=b65f78d4-23f0-4043-bd5e-fea24b5837d3&sessionKey=cc6772fd-65e2-4392-a1ee-24977c99fd2e&touchpoint=desktop&limit=60&skip=0&viewId=production&q=chainsaw&channels=ONLINE%7CSTORE&stores=240'
    ```
  </Tab>

  <Tab title="JS Library">
    ```javascript icon="js" theme={null}
    const api = esales({ clusterId: 'w00000000', market: 'US', locale: 'en-US', touchpoint: 'desktop' });
    const results = await api.query.searchPage({
      q: 'chainsaw',
      channels: 'ONLINE|STORE',
      stores: '240'
    });
    ```
  </Tab>
</Tabs>

### Result

All three chainsaws are returned. If the Only in stock facet had been used, the result would only include two of the three products matching the search phrase `chainsaw`, as the third product, `1001-300`, has no stock level online or in the selected store. Note that the availability array of the `1001-300-1` variant does not include an entry for store `240`, since its `storeStock` entry is omitted for that variant.

```json title="Simplified example result" icon="code" expandable theme={null}
{
  "q": "chainsaw",
  "primaryList": {
    "productGroups": [
      {
        "products": [
          {
            "key": "1001-100",
            ...
            "inStock": true,
            ...
            "variants": [
              {
                "key": "1001-100-1",
                ...
                "inStock": true,
                "stockNumber": 15,
                ...
                "availability": [
                    {
                        "channel": "ONLINE",
                        "stockNumber": 10
                    },
                    {
                        "key": "240",
                        "channel": "STORE",
                        "stockNumber": 5
                    }
                ]
                ...
              }
            ]
            ...
          }
        ],
        "key": "1001"
      },
      {
        "products": [
          {
            "key": "1001-200",
            ...
            "inStock": true,
            ...
            "variants": [
              {
                "key": "1001-200-1",
                ...
                "inStock": true,
                "stockNumber": 10,
                "availability": [
                    {
                        "channel": "ONLINE",
                        "stockNumber": 10
                    },
                    {
                        "key": "240",
                        "channel": "STORE",
                        "stockNumber": 0
                    }
                ]
                ...
              }
            ]
            ...
          }
        ],
        "key": "1001"
      },
      {
        "products": [
          {
            "key": "1001-300",
            ...
            "inStock": false,
            ...
            "variants": [
              {
                "key": "1001-300-1",
                ...
                "inStock": false,
                "stockNumber": 0,
                ...
                "availability": [
                    {
                        "channel": "ONLINE",
                        "stockNumber": 0
                    }
                ]
                ...
              }
            ]
            ...
          }
        ],
        "key": "1001"
      }
    ],
    "totalHits": 3
    ...
  }
}
```

The effects of the parameter combinations for this query are shown below:

| **Channels**    | **Stores** | **Displayed when filtering** | **1001-100 result**                                                                    | **1002-100 result**                                                                    | **1003-100 result**                                                   |
| --------------- | ---------- | ---------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| `ONLINE\|STORE` | `240`      | `1001-100`, `1001-200`       | `inStock`: true<br />`stockNumber`: 15<br />`availability`: online: 10, store `240`: 5 | `inStock`: true<br />`stockNumber`: 10<br />`availability`: online: 10, store `240`: 0 | `inStock`: false<br />`stockNumber`: 0<br />`availability`: online: 0 |

For more information about the parameters, and how parameter combinations affect pages, see [stores and channels](/elevate/docs/integration/site-integration/query-integration/query-parameters#stores-and-channels).
