Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShopperPromotions<ConfigParameters>

*# API Overview

Retrieve information about active promotions within the context of a shopper and a site. You can use this API to retrieve promotions that you configured in the commerce platform by searching for specific promotion IDs or by searching for promotions associated with a campaign.

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

Authentication & Authorization

The Shopper Promotions API requires a JSON Web Token acquired via the Shopper Customers endpoint:

https://{{shortcode}}.api.commercecloud.salesforce.com/customer/shopper-customers/v1/organizations/{{organizationId}}/customers/actions/login

You must include the relevant scope(s) in the client ID used to generate the SLAS token. For details, see Authorization Scopes Catalog.

Use Cases

Get Promotion by Promotion ID

Use the Shopper Promotions API to find promotion information by the promotion ID.

For example, a customer who is browsing on a commerce shopping app built using Commerce Cloud APIs can see the details about the applied promotions in the cart.

Get Promotion by Campaign ID

Use the Shopper Promotions API to find promotion information by the campaign ID.

For example, a customer who is browsing on a commerce shopping app built using Commerce Cloud APIs can see the possible promotions that can be applied in the cart.

Use Hooks

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

Simple example:

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

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

Type parameters

Hierarchy

  • ShopperPromotions

Index

Constructors

constructor

Properties

clientConfig

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

Static Readonly defaultBaseUri

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

Static Readonly paramKeys

paramKeys: { getPromotions: ["organizationId", "siteId", "ids", "locale"]; getPromotionsForCampaign: ["campaignId", "organizationId", "siteId", "startDate", "endDate", "currency"]; getPromotionsForCampaignRequired: ["campaignId", "organizationId", "siteId"]; getPromotionsRequired: ["organizationId", "siteId", "ids"] } = {getPromotions: ['organizationId','siteId','ids','locale',],getPromotionsRequired: ['organizationId','siteId','ids',],getPromotionsForCampaign: ['campaignId','organizationId','siteId','startDate','endDate','currency',],getPromotionsForCampaignRequired: ['campaignId','organizationId','siteId',],} as const

Type declaration

  • getPromotions: ["organizationId", "siteId", "ids", "locale"]
  • getPromotionsForCampaign: ["campaignId", "organizationId", "siteId", "startDate", "endDate", "currency"]
  • getPromotionsForCampaignRequired: ["campaignId", "organizationId", "siteId"]
  • getPromotionsRequired: ["organizationId", "siteId", "ids"]

Methods

getPromotions

  • In the request URL, you can specify up to 50 IDs. If you specify an ID that contains either parentheses or the separator characters, you must URL encode these characters. Each request returns only enabled promotions as the server does not consider promotion qualifiers or schedules.

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

    Parameters

    Returns Promise<PromotionResult>

    A promise of type PromotionResult.

  • In the request URL, you can specify up to 50 IDs. If you specify an ID that contains either parentheses or the separator characters, you must URL encode these characters. Each request returns only enabled promotions as the server does not consider promotion qualifiers or schedules.

    Type parameters

    • T: boolean

    Parameters

    Returns Promise<T extends true ? Response : PromotionResult>

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

getPromotionsForCampaign

  • Retrieves promotion information using filter criteria. In the request URL, you must provide a campaign_id parameter, and you can optionally specify a date range by providing start_date and end_date parameters. Both parameters are required to specify a date range, and omitting one causes the server to return a MissingParameterException fault. Each request returns only enabled promotions, since the server does not consider promotion qualifiers or schedules.

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

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ campaignId: string; currency?: undefined | string; endDate?: undefined | string; organizationId: string; siteId: string; startDate?: undefined | string } & QueryParameters, ConfigParameters> }>

      An object containing the options for this method.

    Returns Promise<PromotionResult>

    A promise of type PromotionResult.

  • Retrieves promotion information using filter criteria. In the request URL, you must provide a campaign_id parameter, and you can optionally specify a date range by providing start_date and end_date parameters. Both parameters are required to specify a date range, and omitting one causes the server to return a MissingParameterException fault. Each request returns only enabled promotions, since the server does not consider promotion qualifiers or schedules.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ campaignId: string; currency?: undefined | string; endDate?: undefined | string; organizationId: string; siteId: string; startDate?: undefined | 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 : PromotionResult>

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

Object literals

Static Readonly apiPaths

apiPaths: object

getPromotions

getPromotions: string = "/organizations/{organizationId}/promotions"

getPromotionsForCampaign

getPromotionsForCampaign: string = "/organizations/{organizationId}/promotions/campaigns/{campaignId}"

Generated using TypeDoc