Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShopperAvailability<ConfigParameters>

*Download API specification

API Overview

Use the Shopper Availability API enables to retrieve inventory availability for products without fetching full product details. This allows independent caching strategies for volatile availability data and stable product data.

Use /availability to retrieve availability for products. If the inventoryIds parameter is omitted, availability is returned from the site-assigned default inventory list. If inventoryIds is provided, availability is returned only from the specified inventory lists.

Caching is provided for the Shopper Availability API. For details, see Server-Side Web-Tier Caching.

Authentication & Authorization

The client requesting the availability information must have access to the Availability resource. The Shopper Availability API requires a shopper access token from the Shopper Login and API Access Service (SLAS).

You must include the relevant scopes in the client ID used to generate the SLAS token. For a full list of required permissions, see the Authorization Scopes Catalog.

For details on how to request a shopper access token from SLAS, see the guest user flows for public clients and private clients in the SLAS guides.

Use Cases

Retrieve Product Availability

Use the Shopper Availability API so that a customer can see whether products are in stock. This API returns availability details, including stock levels and inventory status, for up to 24 products per request.

Retrieve Availability from Specific Inventory Lists

Use the inventoryIds parameter to retrieve availability from specific inventory lists rather than the site-assigned default. This is useful for scenarios such as showing availability at specific store locations or warehouses. You can request availability from up to 5 inventory lists per request.

Retrieve Availability for Product Variations

Use the expand=variations parameter to retrieve availability for all variants of a master product in a single request. Use the productId from each entry in the Shopper Products API variants array to look up availability for a specific variant.

Use Hooks

For details working with hooks, see Extensibility with Hooks.*

Simple example:

  import { ShopperAvailability } from "commerce-sdk-isomorphic";

  const clientConfig = {
    parameters: {
      clientId: "XXXXXX",
      organizationId: "XXXX",
      shortCode: "XXX",
      siteId: "XX"
    }
  };
  const shopperAvailabilityClient = new ShopperAvailability(clientConfig);
API Version: 0.0.33
Last Updated:

Type parameters

Hierarchy

  • ShopperAvailability

Index

Constructors

Properties

Methods

Object literals

Constructors

constructor

Properties

clientConfig

clientConfig: ClientConfig<ConfigParameters> & { baseUri: string }

Static Readonly defaultBaseUri

defaultBaseUri: "https://{shortCode}.api.commercecloud.salesforce.com/product/shopper-availability/v1" = currentBaseUri

Static Readonly paramKeys

paramKeys: { getAvailability: ["organizationId", "productIds", "siteId", "inventoryIds", "expand"]; getAvailabilityRequired: ["organizationId", "productIds", "siteId"] } = {getAvailability: ['organizationId','productIds','siteId','inventoryIds','expand',],getAvailabilityRequired: ['organizationId','productIds','siteId',],} as const

Type declaration

  • getAvailability: ["organizationId", "productIds", "siteId", "inventoryIds", "expand"]
  • getAvailabilityRequired: ["organizationId", "productIds", "siteId"]

Methods

getAvailability

  • Returns availability for multiple products. If inventoryIds is omitted, availability is returned from the site-assigned default inventory list. If inventoryIds is provided, availability is returned only from the specified inventory lists. The maximum number of product IDs that you can request is 24. The maximum number of inventory list IDs you can request is 5. The productIds parameter accepts product IDs for any product type (master, variant, standard, set, or bundle). Products that are offline or not found are silently filtered from the response. To retrieve availability for all variants of a master product, use the expand=variations parameter. Use the productId from each entry in the Shopper Products API variants array to look up availability for a specific variant.

    If you would like to get a raw Response object use the other getAvailability function.

    Parameters

    Returns Promise<AvailabilityResult>

    A promise of type AvailabilityResult.

  • Returns availability for multiple products. If inventoryIds is omitted, availability is returned from the site-assigned default inventory list. If inventoryIds is provided, availability is returned only from the specified inventory lists. The maximum number of product IDs that you can request is 24. The maximum number of inventory list IDs you can request is 5. The productIds parameter accepts product IDs for any product type (master, variant, standard, set, or bundle). Products that are offline or not found are silently filtered from the response. To retrieve availability for all variants of a master product, use the expand=variations parameter. Use the productId from each entry in the Shopper Products API variants array to look up availability for a specific variant.

    Type parameters

    • T: boolean

    Parameters

    Returns Promise<T extends true ? Response : AvailabilityResult>

    A promise of type Response if rawResponse is true, a promise of type AvailabilityResult otherwise.

Object literals

Static Readonly apiPaths

apiPaths: object

getAvailability

getAvailability: string = "/organizations/{organizationId}/availability"

Generated using TypeDoc