The Qualifier class contains two protected methods, evaluateQualifier and evaluateTarget, that are responsible for evaluating different elements of a PMDL (discount) rule.

The evaluateQualifier method determines if the input environment (the pricing context) satisfies the constraints of the qualifier rule. The input environment is represented by the parameters passed into the method. If the constraints are satisfied, evaluateQualifier determines which objects acted as qualifiers in satisfying the rule. For more information, see the Evaluating Qualifiers Example section

For example, in the rule “Buy 1 shirt, get 1 hat free,” the “one shirt” element of the rule is evaluated through evaluateQualifier. The method returns the shirt item that satisfies the constraint.

Not all rules need qualifiers. Consider the PMDL rule “When there is at least 1 blue item, discount 1 green item.” In this example, the qualifier rule does not require a customer to buy one blue item in order to receive a discount on one green item. The rule requires only that one blue item be in the input environment. In this case, the qualifier just returns a java.lang.Boolean indicating whether or not the environment matched the rule.

The evaluateTarget method is invoked only in situations where the Qualifier must select objects for discounting from a larger pool of available objects. (See the information above on filterItems for more details.) This situation occurs only for discounts on CommerceItems. In the example “When there is at least 1 blue item, discount up to 1 green item,” the “green item” element of the rule is evaluated through the evaluateTarget method. It selects one green item to discount from all the items in the environment.

loading table of contents...