Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShopperProducts<ConfigParameters>

*# API Overview

The Shopper Products API enables you to access product details for products that are online, merchandised to a particular site catalog, and ready to be sold. You can use these product details to merchandise the product on other ecommerce channels. To set up category navigation paths on other commerce apps or storefronts, you can use the Categories API.

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

Authentication & Authorization

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

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

Populate Product Listing Pages

Use the Shopper Product API so that a customer, browsing on a commerce shopping app built using Commerce Cloud APIs, can see a list of products. For example, hydrate a list of products (max 24). The API returns product details including images, prices, promotions, and product availability.

b2c-commerce-shopper-products-screenshot-1.png

Get Variation Product Details on an Ecommerce Channel

Use the API so that a customer, browsing on a commerce shopping app built using Commerce Cloud APIs, can switch between different variation products. The API returns product details including images, prices, promotions, and available to sell inventory.

b2c-commerce-shopper-products-screenshot-2.png

Retrieve Promotion Information

Promotions provide discounts to shoppers when they meet certain purchase requirements.

Promotion information is described in detail in Promotion Details, but the following list provides several key points:

  • Pricing discounts for basket and shipping promotions are NEVER returned by the 'getProduct' or 'getProducts' endpoint.
  • Promotional pricing is ONLY returned for products that are included with non-conditional promotions.
  • Callout messages are ALWAYS returned by the 'getProduct' and 'getProducts' endpoints.

By default, 'getProduct' and 'getProducts' return promotion information for a queried product. Promotion information includes both pricing and callout message information. However, the specific pricing and callout information that is fetched is determined by:

  • Promotion Type
  • Product Type
  • Product Purchase Requirements

Some promotions can be displayed on a Product Data Page (PDP) or Product Listing page (PLP), while other promotions are displayed in the context of a basket, such as an order level promotion: "add the product to your basket to view price information". It is important to understand what is included in the response when designing a PDP or PLP on top of SCAPI to ensure your design aligns with implementable features.

Shopper Personalization

The SCAPI response can be personalized using the Shopper Context API or hooks. By setting specific values in the Shopper Context API, you can modify the response of the 'getProduct' or 'getProducts' endpoint based on the shopper's context. For instance, you can offer a 5% discount or free shipping to shoppers using mobile devices.

JWA Caching

The response is cached in JWA, which means promotion data contained in the response is also cached based on the TTL (Time to Live) specified in the Business Manager Feature Switches configuration. When the shopper context value is updated, a check is conducted to see if the updated shopper context affects the retrieval of product-promotion data. If it does, then the response is fetched from the source and cached in the JWA.

For details, see Server-Side Web-Tier Caching.

Use Hooks

For details working with hooks, see Extensibility with Hooks.

Test Description Changes

uoweefhewihpfhweipfiphwefhipwehfiewpifhewifiphehipeipwhfhipewfhiihpefipew

Resources

Product

A full representation of a product or service that is to merchandise. A ready to merchandise product is one that is online, categorized, and published to a channel. The information associated with a product includes, the product name, description, custom and system attributes, variations, price, availability, and images.

Category

Categories and subcategories are the structure by which products are organized and grouped in a catalog and on a storefront. Categories can have relationships to other categories. Further, each category can provide context that is inherited by subcategories. For example, a category can have an assigned attribute. A product assigned to that category or any subcategory inherits the categories’s attribute value. Once the product is removed from the category, the attribute value is no longer inherited by the product. You can also use category linking for site hierarchical navigation. For example, inside the Clothing category you may have Men’s, and inside the Men’s category you may have Pants.

Categories are not tags.

Endpoints

GET /products

Returns product details for up to 24 products in one API request. You can use this API for use cases that require populating or hydrating multiple products at a time, such as populating the Product Listing Pages.

The response data includes availability, promotions, images, and prices, along with the basic product information for the products requested.

GET /products/{id}

Returns product details about a single product. Use this API for use cases that require populating or hydrating one product at a time, such as the Product Detail Pages.

The response data includes availability, promotions, options, images, prices, variations, bundled_products, set_products, recommendations, and the basic product information for the product requested.

GET /categories

Returns category details including the parent child relationships for one or more categories. The limit on depth for the parent-child relationship is 2.*

Simple example:

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

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

Type parameters

Hierarchy

  • ShopperProducts

Index

Constructors

constructor

Properties

clientConfig

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

Static Readonly defaultBaseUri

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

Static Readonly paramKeys

paramKeys: { getCategories: ["organizationId", "ids", "siteId", "levels", "locale"]; getCategoriesRequired: ["organizationId", "ids", "siteId"]; getCategory: ["id", "organizationId", "siteId", "levels", "locale"]; getCategoryRequired: ["id", "organizationId", "siteId"]; getProduct: ["organizationId", "id", "siteId", "inventoryIds", "expand", "allImages", "perPricebook", "select", "currency", "locale"]; getProductRequired: ["organizationId", "id", "siteId"]; getProducts: ["organizationId", "ids", "siteId", "inventoryIds", "expand", "allImages", "perPricebook", "select", "locale", "currency"]; getProductsRequired: ["organizationId", "ids", "siteId"] } = {getCategories: ['organizationId','ids','siteId','levels','locale',],getCategoriesRequired: ['organizationId','ids','siteId',],getCategory: ['id','organizationId','siteId','levels','locale',],getCategoryRequired: ['id','organizationId','siteId',],getProduct: ['organizationId','id','siteId','inventoryIds','expand','allImages','perPricebook','select','currency','locale',],getProductRequired: ['organizationId','id','siteId',],getProducts: ['organizationId','ids','siteId','inventoryIds','expand','allImages','perPricebook','select','locale','currency',],getProductsRequired: ['organizationId','ids','siteId',],} as const

Type declaration

  • getCategories: ["organizationId", "ids", "siteId", "levels", "locale"]
  • getCategoriesRequired: ["organizationId", "ids", "siteId"]
  • getCategory: ["id", "organizationId", "siteId", "levels", "locale"]
  • getCategoryRequired: ["id", "organizationId", "siteId"]
  • getProduct: ["organizationId", "id", "siteId", "inventoryIds", "expand", "allImages", "perPricebook", "select", "currency", "locale"]
  • getProductRequired: ["organizationId", "id", "siteId"]
  • getProducts: ["organizationId", "ids", "siteId", "inventoryIds", "expand", "allImages", "perPricebook", "select", "locale", "currency"]
  • getProductsRequired: ["organizationId", "ids", "siteId"]

Methods

getCategories

  • When you use the URL template, the server returns multiple categories (a result object of category documents). You can use this template to obtain up to 50 categories in a single request. You must enclose the list of IDs in parentheses. If a category identifier contains parenthesis or the separator sign, you must URL encode the character.

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

    Parameters

    Returns Promise<CategoryResult>

    A promise of type CategoryResult.

  • When you use the URL template, the server returns multiple categories (a result object of category documents). You can use this template to obtain up to 50 categories in a single request. You must enclose the list of IDs in parentheses. If a category identifier contains parenthesis or the separator sign, you must URL encode the character.

    Type parameters

    • T: boolean

    Parameters

    Returns Promise<T extends true ? Response : CategoryResult>

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

getCategory

  • When you use the URL template, the server returns a category identified by the ID. By default, the server also returns the first level of subcategories, but you can specify an additional level using the levels parameter.

    This endpoint fetches both online and offline categories. For offline categories, only the top-level category is returned, not offline subcategories.

    Using a large value for levels can cause performance issues when there is a large and deep category tree.

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

    Parameters

    Returns Promise<Category>

    A promise of type Category.

  • When you use the URL template, the server returns a category identified by the ID. By default, the server also returns the first level of subcategories, but you can specify an additional level using the levels parameter.

    This endpoint fetches both online and offline categories. For offline categories, only the top-level category is returned, not offline subcategories.

    Using a large value for levels can cause performance issues when there is a large and deep category tree.

    Type parameters

    • T: boolean

    Parameters

    Returns Promise<T extends true ? Response : Category>

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

getProduct

  • Allows access to product details for a single product ID. Only products that are online and assigned to a site catalog are returned. In addition to product details, the availability, images, price, bundled_products, set_products, recommedations, product options, variations, and promotions for the products are included, as applicable.

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

    Parameters

    Returns Promise<Product>

    A promise of type Product.

  • Allows access to product details for a single product ID. Only products that are online and assigned to a site catalog are returned. In addition to product details, the availability, images, price, bundled_products, set_products, recommedations, product options, variations, and promotions for the products are included, as applicable.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ allImages?: undefined | false | true; currency?: CurrencyCode; expand?: Array<GetProductExpandEnum>; id: string; inventoryIds?: Array<string>; locale?: LocaleCode; organizationId: string; perPricebook?: undefined | false | true; select?: undefined | string; siteId: string } & QueryParameters, ConfigParameters> }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true ? Response : Product>

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

getProducts

  • Allows access to multiple product details with a single request. Only products that are online and assigned to a site catalog are returned. The maximum number of product IDs that you can request is 24. In addition to product details, the availability, product options, images, price, promotions, and variations for the valid products are included, as applicable.

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

    Parameters

    Returns Promise<ProductResult>

    A promise of type ProductResult.

  • Allows access to multiple product details with a single request. Only products that are online and assigned to a site catalog are returned. The maximum number of product IDs that you can request is 24. In addition to product details, the availability, product options, images, price, promotions, and variations for the valid products are included, as applicable.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ allImages?: undefined | false | true; currency?: CurrencyCode; expand?: Array<GetProductsExpandEnum>; ids: Array<string>; inventoryIds?: Array<string>; locale?: LocaleCode; organizationId: string; perPricebook?: undefined | false | true; select?: undefined | string; siteId: string } & QueryParameters, ConfigParameters> }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true ? Response : ProductResult>

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

Object literals

Static Readonly apiPaths

apiPaths: object

getCategories

getCategories: string = "/organizations/{organizationId}/categories"

getCategory

getCategory: string = "/organizations/{organizationId}/categories/{id}"

getProduct

getProduct: string = "/organizations/{organizationId}/products/{id}"

getProducts

getProducts: string = "/organizations/{organizationId}/products"

Generated using TypeDoc