Understand PMDL discount rules

The Price Model Definition Language (PMDL) describes Oracle Commerce Cloud promotions internally.

PMDL describes the rules for when a promotion may apply (the condition), the rules for what may be discounted (the offer), and how to apply the discount (for example, 10% off).

This section describes the XML used for constructing discount rules that represent promotions in Oracle Commerce Cloud.

PMDL XML structure

The PMDL that describes promotions discount rules is relatively simple. The DTD defines the following to use in your PMDL rules:

  • Iterators such as next, up-to-and-including and every.
  • Quantifiers that are used in WHEN conditions, such as at-least, at-most, exactly and all.
  • Operators such as and, or and not.
  • Comparators such as starts-with, ends-with, contains, greater-than, less-than and equals, which compare values and/or arrays.
  • Operations such as union and anded-union.
  • Value types such as constant or null.
  • Array types such as constant or value.

The PMDL DTD contains the following elements:

Pricing-Model element

The pricing-model element is the root tag for the PMDL.

Offer element

Every pricing-model requires one offer element. The offer includes one or more discount-structure elements, which contain detailed information about the discount and its target.

You can include more than one discount-structure element in an offer; this allows you to wrap multiple discounts in a single promotion (note that this is not supported in Merchandising, but you can build a custom template with this functionality).

If you have multiple discount structures within a single item promotion, you can specify the filter-collection-name attribute of the offer; this ensures that once a given item has been marked to receive a discount, it cannot receive a discount from any other discount-structures. If filter-collection-name is not set, filtering does not take place, and a given commerce item can be the target for more than one discount. The filter-collection-name should match the iterator element’s collection-name attribute, which is normally set to items. Filtering is not required for single discount structures, or for non-item-based promotions.

Qualifier Element

Every pricing-model requires one qualifier element. The qualifier is the root tag for the promotion’s buy condition.

Target Element

The target specifies the rule for selecting the items to be discounted. Your discount structure should not include a target element if the promotion is for orders or shipping; only item discounts include target as part of the discount-structure.

Discount-Structure element

The discount-structure element has the following attributes:

  • calculator-type: A calculator service configured in the pricing engine. For all Oracle Commerce Cloud promotions, the value for calculator-type is standard.
  • discount-type: The calculators use this value to determine how to calculate an adjustment. Valid values are: percentOff, amountOff, free, and fixedPrice.
  • adjuster: This optional attribute specifies the price adjustment to make for this discount. For example, the following discount structure element specifies that the promotion should discount the target by 50%:
<discount-structure calculator-type="standard" discount-type="percentOff" adjuster="50"></discount-structure>

Attribute element

The attribute element allows you to add generic name/value pairs to parent tags, similar to the process used to extend a Core Commerce repository. During PMDL parsing, the attributes and their values are placed in an attribute Map.

Iterator element

An iterator sorts a collection of items, then evaluate each item against one or more sub-expressions. It returns those items that match the sub-expressions.

The iterator element allows you to create custom iterators. Your new iterator element must include a name attribute that is unique across the PMDL.

An iterator element can have the following attributes and sub-elements:

  • name attribute (required)
  • sort-by attribute (required)
  • sort-order attribute (required)
  • collection-name (required)
  • element-name (required)
  • element-quantity-property

Quantifier element

Quantifiers are evaluation beans that evaluate a collection of items against one or more sub-expressions. It returns true or false, depending on the quantity of items that match the sub-expressions.

The quantifier element allows you to create custom quantifiers. Your new quantifier element must include a name attribute that is unique across the PMDL.

A quantifier element can have the following attributes and sub-elements:

  • name attribute (required)
  • number attribute
  • collection-name (required)
  • element-name (required)
  • element-quantity-property

Operator element

Operators return true or false based on the Boolean results from their sub-expressions.

The operator element allows you to create custom operators. Your new operator element must include a name attribute that is unique across the PMDL.

An operator element can specify any number of attribute sub-elements and operates on at least one comparator, operator or quantifier.

Comparator element

Comparators return true or false depending on the values of their sub-expressions.

The comparator element allows you to create custom comparators. Your new comparator element must include a name attribute that is unique across the PMDL. A comparator element can specify any number of attribute sub-elements and must specify at least one value or array name.

Comparators evaluate using one or more sub-expressions. For example:

<comparator name="includes-any">

Comparators can also compare two value elements, and custom comparators could include any number of value or constant elements.

Value element

The value element returns the value of a property of the item the promotion is evaluating. You must include the value element for Buy One Get One promotions as follows:

<value>item.auxiliaryData.productRef.ancestorCategoryIds</value>

Constant element

The constant element returns a constant value against which other values can be compared. For example:

<constant>
 <data-type>java.lang.String</data-type>
 <string-value>xprod2147</string-value>
</constant>