Assign a Price Book or Promotion to a Specific Store in B2C Commerce

With Store-Specific Pricing and Promotions, select a price book for each of your stores, up to 2,000. The assignments framework lets merchants and developers set qualifiers, such as a store that activates certain experiences, such as a promotion. You can also assign a promotion to a specific store. This feature is only supported via XML import. To use a site assignment, a developer must first edit the assignments XML to include a store assignment. Currently only stores can be listed as assignments.

  1. Click App Launcher App Launcher, and then select Merchant Tools | Site | Online Marketing | Import & Export.
  2. Click Import in the Assignments section.
  3. Select the file with your assignments and click Next.
  4. Consider the following sample code for assignments.
    <?xml version="1.0" encoding="UTF-8"?>
    <assignments xmlns="http://www.demandware.com/xml/impex/assignment/2020-11-30">
        <assignment assignment-id="Storeassignment_A">
            <description xml:lang="x-default">Price books and promotions assigned to Store A</description>
            <description xml:lang="zh-CN">万能青年旅店</description>
            <enabled-flag>true</enabled-flag>
            <start-date>2020-11-24T00:00:00.000Z</start-date>
            <end-date>2025-11-24T00:00:00.000Z</end-date>
            <assigned-sites>
                <site>SiteGenesis</site>
                <site>SiteGenesisGlobal</site>
            </assigned-sites>
            <qualifiers match-mode="any">
                <qualifier type="STORE">Store A</qualifier>
            </qualifiers>
            <experiences>
                <pricebooks>
                    <pricebook-id>list_pricebook</pricebook-id>
                    <pricebook-id>sale_pricebook</pricebook-id>
                </pricebooks>
                <promotions>
                    <promotion-id>20%Off_promotion</promotion-id>
                </promotions>
            </experiences>
        </assignment>
    ​
    </assignments>

See the status of your file. Hit refresh until the import concludes. The import can take a few minutes.

To display store-specific experiences on the storefront, a developer must update their Salesforce Reference Architecture (SFRA) cartridge or write an Open Commerce API (OCAPI) hook to set the store in session. To set the store Id in session for SFRA, use the setStoreIDToSession() method. For example: StoreMgr.setStoreIDToSession('0335').

In Shopper Commerce API (SCAPI), the qualifier is case-sensitive for createShopperContext and updateShopperContext depending on however you’ve set the qualifier type in the XML. For example:

{
    "assignmentQualifiers": {
        "STORE": "0335"
    }
}