Create custom promotions for shared carts

When creating promotions, you may want to create customized promotions for shoppers who use shared carts.

You can allow your shoppers to access multiple sites while using a single cart. Creating shared carts allows your customers to shop from any site that you add to a cart sharing group, which lets them add items to their shopping cart without having to log out of and log into different sites or manage multiple orders. For information on working with Shared Carts, refer to Create Shared Carts.

Sometimes, you may want to identify promotions that apply only to a single site that is part of a cart sharing group. Or, you may want to define site-specific promotions for multiple sites within a cart sharing group. To do this, use the Admin API to create a promotion with custom Pricing Model Definition Language (PMDL).

Create a site-specific promotion

When you create a promotion, you use PMDL to describe the promotions. PMDL provide the rules for conditions that trigger the promotion. They also indicate what may be discounted and how to apply the discount. You create a rawPmdlTemplate promotion by issuing a POST command to the /ccadmin/v1/promotions endpoint. For detailed information on working with PMDL, refer to Understand PMDL discount rules.

The following PMDL example shows two different pricing models. The first site-specific promotion offers a 20% discount for items that are added to the shopper's cart from the USStore site. The second site-specific promotion offers a 40% discount for items that are added to the shopper's cart from the UKStore site.
<pricing-model>
  <qualifier/>
  <offer>
    <discount-structure calculator-type="standard" discount-type="percentOff" adjuster="20">
      <target>
        <iterator name="up-to-and-including" number="-1" sort-by="priceInfo.listPrice" sort-order="ascending">
          <collection-name>items</collection-name>
          <element-name>item</element-name>
          <element-quantity-property>quantity</element-quantity-property>
          <comparator name="equals">
            <value>item.siteId</value>
            <constant>
              <data-type>java.lang.String</data-type>
              <string-value>USStore</string-value>
            </constant>
          </comparator>
        </iterator>
      </target>
    </discount-structure>
  </offer>
</pricing-model>
  
<pricing-model>
  <qualifier/>
  <offer>
    <discount-structure calculator-type="standard" discount-type="percentOff" adjuster="40">
      <target>
        <iterator name="up-to-and-including" number="-1" sort-by="priceInfo.listPrice" sort-order="ascending">
          <collection-name>items</collection-name>
          <element-name>item</element-name>
          <element-quantity-property>quantity</element-quantity-property>
          <comparator name="equals">
            <value>item.siteId</value>
            <constant>
              <data-type>java.lang.String</data-type>
              <string-value>UKStore</string-value>
            </constant>
          </comparator>
        </iterator>
      </target>
    </discount-structure>
  </offer>
</pricing-model>

The request payload may be something similar to the following:

{
  "displayName": "20% off All US Store items",
  "description": "20% off All US Store items",
  "filterForQualifierActedAsQualifier": false,
  "filterForTargetActedAsQualifier": false,
  "priceListGroups": [
    "defaultPriceGroup"
  ],
  "enabled": true,
  "priority": "1",
  "templatePath": "item",
  "templateName": "rawPmdlTemplate",
  "templateValues": {
    "pmdl": {
      "xml": "<pricing-model><qualifier/><offer><discount-structure calculator-type=\"standard\"
         discount-type=\"percentOff\" adjuster=\"20\">
      <target><iterator name=\"up-to-and-including\" number=\"-1\" sort-by=\"priceInfo.listPrice\"
         sort-order=\"ascending\">
      <collection-name>items</collection-name><element-name>item</element-name>
         <element-quantity-property>quantity</element-quantity-property>
      <comparator name=\"equals\"><value>item.siteId</value><constant>
         <data-type>java.lang.String</data-type><string-value>USStore</string-value>
      </constant></comparator></iterator></target></discount-structure></offer>
         </pricing-model>"
    }
}

Or the following request:


{
  "displayName": "40% off All UK Store items",
  "description": "40% off All UK Store items",
  "filterForQualifierActedAsQualifier": false,
  "filterForTargetActedAsQualifier": false,
  "priceListGroups": [
    "defaultPriceGroup"
  ],
  "enabled": true,
  "priority": "1",
  "templatePath": "item",
  "templateName": "rawPmdlTemplate",
  "templateValues": {
    "pmdl": {
      "xml": "<pricing-model><qualifier/><offer><discount-structure calculator-type=\"standard\"
         discount-type=\"percentOff\" adjuster=\"40\">
      <target><iterator name=\"up-to-and-including\" number=\"-1\" sort-by=\"priceInfo.listPrice\"
         sort-order=\"ascending\">
      <collection-name>items</collection-name><element-name>item</element-name>
         <element-quantity-property>quantity</element-quantity-property>
      <comparator name=\"equals\"><value>item.siteId</value><constant>
         <data-type>java.lang.String</data-type><string-value>UKStore</string-value>
      </constant></comparator></iterator></target></discount-structure></offer>
         </pricing-model>"
    }
  }
}

For additional information on working with PMDL, refer to Understand PMDL discount rules.

Understand promotion filters

Promotions can be filtered, which allows you to perform a number of actions, such as exclude or include qualified items, or include items that are on sale. Filters, which are boolean properties, are based on qualifying conditions or offers presented by the promotion:
"displayName": "40% off All UK Store items",
  "description": "40% off All US Store items",
  "filterForQualifierActedAsQualifier": false,
  "filterForTargetActedAsQualifier": false,
The following filters are available for promotions:
Filter Property Description Used on promotions
filterForQualifierActedAsQualifier This conditional filter allows you to identify if a qualifier can be reused in a promotion. Item, Order or Shipping promotions.
filterForQualifierDiscountedByAny This conditional filter allows you to determine if items discounted by any promotion can act as a qualifier for other promotions. Item, Order or Shipping promotions.
filterForQualifierDiscountedByCurrent This conditional filter determines if items that are discounted by the current promotion can act as qualifiers for other promotions. Item promotions.
filterForQualifierOnSale This conditional filter identifies if items that have a sales price can act as a qualifier. Item, Order or Shipping promotions.
filterForQualifierZeroPrices This conditional filter determines if items that have a zero price can act as a qualifier. Item, Order or Shipping promotions.
filterForQualifierNegativePrices This conditional filter identifies if items with negative prices can act as qualifiers. Item, Order or Shipping promotions.
filterForTargetActedAsQualifier This offer filter determines if items that have acted as a qualifier for any discount can be applied to the current discount. Item promotions only.
filterForTargetDiscountedByAny This offer filter determines if items that have been discounted by any promotion can receive another discount. Item promotions only.
filterForTargetDiscountedByCurrent This offer filter determines if items that have already been discounted by the current promotion can receive the discount again. Item promotions only.
filterForTargetOnsale This offer filter identifies if items that were priced with a sales price are allowed to receive the current discount. Item promotions only.
filterForTargetZeroPrices This offer filter determines if items with zero prices can receive the discount. Item promotions only.
filterForTargetNegativePrices This offer filter determines if items with negative prices can receive the discount. Item promotions only.
filterForTargetPriceLTOETPromoPrice This offer filter determines if it should exclude items with prices lower than the promotion price. Item promotions only.

For detailed information on working with these filters, refer to the REST API documentation for Promotions.