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

# Buy online, pick up in store (BOPIS)

> Enable store-level availability filtering and pick up in-store experiences with Algolia for Salesforce B2C Commerce.

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

**Buy online, pick up in-store** (BOPIS) lets shoppers reserve or pay for an item online and collect it from a physical store.
This guide shows you how to index store-level stock information and add an **In stock at store** facet to your storefront.

BOPIS indexing:

* Adds a `storeAvailability` attribute that contains the IDs of stores where a variant is available.
* Sends this attribute with every product (variant or product level, depending on your [record model](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#record-models)).

It only indicates if the product is available in the store, not the number of available products.

## Before you begin

This feature requires:

* Algolia Search & Discovery cartridge **25.3.0** or later
* Salesforce's [`plugin_instorepickup`](https://github.com/SalesforceCommerceCloud/plugin_instorepickup) cartridge

Some controllers in `plugin_instorepickup` fully replace SFRA endpoints instead of extending them.
Place the `plugin_instorepickup` cartridge before `app_storefront_base` and after the Algolia cartridges.
This order ensures that Algolia extensions to these endpoints aren't overridden (for example, `Cart-AddProduct`).

<Note>
  The `plugin_instorepickup` cartridge relies on features from [B2C Compatibility Mode 21.2](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-compatibility-mode-considerations.html#212), such as `Number.isNaN()`.
  If you use compatibility mode [19.10](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-compatibility-mode-considerations.html#1910) or [18.10](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-compatibility-mode-considerations.html#1810) (the minimum supported by the Algolia cartridge), you may encounter errors.
  To resolve these errors, update to compatibility mode 21.2 or later, or adjust the `plugin_instorepickup` cartridge.
</Note>

If you enable [real-time inventory updates](/doc/integration/salesforce-commerce-cloud-b2c/guides/realtime-updates), the `storeAvailability` attribute is updated with the latest inventory level after an order is placed.

## Enable store-inventory indexing

1. Go to **Merchant Tools > Algolia > Algolia** in the [Business Manager](/doc/integration/salesforce-commerce-cloud-b2c/getting-started/set-up-the-algolia-cartridge?client=javascript#enable-algolia-in-the-business-manager).
2. In **Additional Product Attributes**, append `storeAvailability` and click **Apply**. Indexing jobs will now recognize this attribute.

During indexing, the cartridge:

* Retrieves each variant's available‑to‑sell (ATS) value per store.
* Adds the store's ID to `storeAvailability` if the ATS is **≥ In Stock Threshold** (defined in your [custom preferences](/doc/integration/salesforce-commerce-cloud-b2c/getting-started/custom-preferences)).

```jsonc JSON icon=braces theme={"system"}
// Variant‑level example
{
  "objectID": "25523741-blue-xs",
  "name": "Essential Tee",
  "storeAvailability": ["paris_store", "berlin_store"]
}
```

Attribute location:

| Record model        | Location of `storeAvailability`           |
| ------------------- | ----------------------------------------- |
| **Base product**    | Inside every item in the `variants` array |
| **Variant product** | At the root level of the record           |

### Understand the size impact

If you run hundreds of stores, `storeAvailability` can add several kilobytes per record.
To limit the impact:

* Use short store IDs or a custom mapping that translates an abbreviated ID to a friendly name on the frontend.
* Use [post processing](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#post-processing-customization) to filter out stores that aren't relevant to your business.

## Add an **In stock at store** facet

After the attribute exists in your <Index />, create a facet:

1. Open your **products** index in the Algolia dashboard.
2. Go to **Configuration > Facets** and add `storeAvailability` as a **attributesForFaceting**.
3. Save the settings.

### How the storefront resolves the "Store" facet

1. The SFRA Search controller passes a JSON array of store details to `searchResultsNoDecorator.isml` as `pdict.storeList`.
2. The `storeAvailability` field in each product record includes a `storeIds` array that lists the stores carrying the item.
3. When the store facet renders, every store ID is looked up in `pdict.storeList`. The frontend displays store names in place of the IDs.
