Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Promotions

*# API Overview

Use the Promotions API to create, update, delete, and search for promotion information on your site. Promotions are configured with rules that define the type of promotion, conditions, and discounts.

This API can be used to synchronize promotion data in the commerce platform with third-party promotion management systems. This API can also be called from a custom promotion management application. In sandbox environments, the Promotions API is useful for creating and updating test data, for example, with integration testing or as part of a continuous integration or continuous deployment process.

For more information, see Campaigns and Promotions in the Salesforce B2C Commerce Infocenter.

Authentication & Authorization

The client requesting the promotion information must have access to the Promotion resource. For resource access, you must use a client ID and client secret from Account Manager to request an access token. The access token is used as a bearer token and added to the Authorization header of your API request. The client must first authenticate against Account Manager to log in.

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

For detailed setup instructions, see Authorization for Admin APIs.

Use Cases

Note*: A promotion can be created, enabled, and assigned exclusivity using the API, but qualifier and discounted criteria must be assigned in Business Manager.

Shipping Promotions

Use the Promotions API to configure shipping promotions.

You can configure shipping promotions based on an order and on individual products or product combinations. You can also configure product-specific shipping cost (fixed or surcharge).

Note*: Product-related shipping discounts are considered product promotions.

In a multiple ship-to scenario, B2C Commerce determines which shipments use any of the discounted shipping methods and applies the discount from most expensive to least expensive until meeting the maximum applications limit, if specified.

For example, create a shipping promotion that gives the customer free shipping when their purchase exceeds $50.

For more detail, see Shipping Promotions in the Salesforce B2C Commerce Infocenter.

Product Promotions

Use the Promotions API to configure product promotions.

You can define product promotions for specific products, groups of products or brands, or amounts of products purchased. You can define conditions that require customers to purchase from a set of products.

A product promotion is prorated, calculated, and rounded once per product in the order. A product promotion is different than an order promotion, which is calculated once at the order level, and rounded off once, if necessary.

For example, create a product promotion that discounts a second item by 50% when the customer buys two.

For more detail, see Product Promotions in the Salesforce B2C Commerce Infocenter.

Order Promotions

Use the Promotions API to configure order promotions.

You can configure order promotions for percentage discounts, fixed price discounts, and free shipping. You can offer a bonus product or a choice of bonus products, and you can tier order discounts.

An order promotion is calculated once at the order level, and rounded off once, if necessary. An order promotion is different than a product promotion, where the promotion is prorated, calculated, and rounded per product in the order.

For example, create an order promotion that discounts an entire order when the customer buys 3 qualifying items.

For more detail, see Order Promotions in the Salesforce B2C Commerce Infocenter.*

For instructions on how to retrieve access token for admin APIs: https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html

Example with admin auth

import { Promotions, ClientConfig } from "commerce-sdk";
// or
const { Promotions, ClientConfig } = require("commerce-sdk");

const clientConfig: ClientConfig = {
  parameters: {
    clientId: "XXXXXX",
    organizationId: "XXXX",
    shortCode: "XXX",
    siteId: "XX"
  }
};

token = { access_token: 'INSERT_ACCESS_TOKEN_HERE' };

clientConfig.headers['authorization'] = `Bearer ${token.access_token}`;
const promotionsClient = new Promotions(clientConfig);
API Version: 1.4.4
Last Updated:

Hierarchy

  • BaseClient
    • Promotions

Index

Constructors

constructor

  • new Promotions(config: ClientConfig): Promotions
  • Parameters

    • config: ClientConfig

    Returns Promotions

Properties

clientConfig

clientConfig: ClientConfig

Methods

createPromotion

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

    Parameters

    Returns Promise<Promotion>

    A promise of type Promotion.

  • Type parameters

    • T: boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{ body: Promotion; fetchOptions?: RequestInit; headers?: {}; parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions }>

      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 : Promotion>

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

deletePromotion

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

    Parameters

    Returns Promise<void>

    A promise of type void.

  • Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ fetchOptions?: RequestInit; headers?: {}; parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions }>

      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 : void>

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

getPromotion

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

    Parameters

    Returns Promise<Promotion>

    A promise of type Promotion.

  • Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ fetchOptions?: RequestInit; headers?: {}; parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions }>

      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 : Promotion>

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

promotionsSearch

  • The SearchRequest document contains a search object that allows you to filter using various attributes.

    Use the following searchable query attributes to narrow down the search:

    Attribute Type
    id String
    name String
    currecyCode String
    exclusivity String
    enabled Boolean

    Note that only searchable attributes can be used in sorting. Additionally, the following attribute can be used to sort:

    Attribute Type
    promotionClass String

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

    Parameters

    Returns Promise<PromotionSearchResult>

    A promise of type PromotionSearchResult.

  • The SearchRequest document contains a search object that allows you to filter using various attributes.

    Use the following searchable query attributes to narrow down the search:

    Attribute Type
    id String
    name String
    currecyCode String
    exclusivity String
    enabled Boolean

    Note that only searchable attributes can be used in sorting. Additionally, the following attribute can be used to sort:

    Attribute Type
    promotionClass String

    Type parameters

    • T: boolean

    Parameters

    Returns Promise<T extends true ? Response : PromotionSearchResult>

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

updatePromotion

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

    Parameters

    Returns Promise<Promotion>

    A promise of type Promotion.

  • Type parameters

    • T: boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{ body: Promotion; fetchOptions?: RequestInit; headers?: {}; parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions }>

      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 : Promotion>

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

Generated using TypeDoc