Understand PMDL discount rules
The Price Model Definition Language (PMDL) describes Oracle Commerce promotions internally.
This section applies to Open Storefront Framework (OSF) and Storefront Classic.
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.
PMDL XML structure
The PMDL is used to describe promotions discount rules. The DTD defines the following to use in your PMDL rules:
- Iterators such as
next
,up-to-and-including
andevery
. - Quantifiers that are used in
WHEN
conditions, such asat-least
,at-most
,exactly
andall
. - Operators such as
and
,or
andnot
. - Comparators such as
starts-with
,ends-with
,contains
,greater-than
,less-than and equals
, which compare values and/or arrays. - Operations such as
union
andanded-union
. - Value types such as
constant
or null. - Array types such as
constant
orvalue
.
The PMDL DTD contains the following elements:
Pricing-Model element
The pricing-model
element is the root tag for the PMDL. The pricing-model
determines what to discount, how to discount it, and by how much.
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.
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
element is used in item discounts to specify the rule for selecting which items are discounted. Order and shipping discounts do not have a target
element in 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 promotions, the value forcalculator-type
isstandard
.discount-type
: The calculators use this value to determine how to calculate an adjustment. Valid values are:percentOff
,amountOff
,free
, andfixedPrice
.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. During PMDL parsing, the attributes and their values are placed in an attribute Map. There are also predefined iterators: next
, up-to-and-including
and every
.
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 evaluate a collection of items against one or more sub-expressions. Quantifiers are used in WHEN
conditions, such as at-least
, at-most
, exactly
and all
.
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
attributecollection-name
(required)element-name
(required)element-quantity-property
Operator element
Operators return and
, or
, not
, 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. Comparators such as starts-with
, ends-with
, contains
, greater-than
, less-than
and equals
, compare values and/or arrays.
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>