The existing Qualifier helper methods use two methods to filter items out of the environment before comparing it to a promotion’s PMDLRule. The filtering process prevents problems with pricing rules. For example, in the promotion “buy one item, get one item free,” most retailers exclude the item that acts as a qualifier from receiving the discount. This behavior prevents a customer from buying just one item and getting that one item free. (The customer must put two items in the cart in order to get the discount.) The filterItemsForQualifier and filterItemsForTarget methods in Qualifier implement this behavior.

The filterItemsForQualifier and filterItemsForTarget methods correspond to two parts of a PMDL rule: the qualifier rule and the target rule. See the Using PMDL Rules section for more information.

  • filterItemsForQualifier: Every PMDL rule has a qualifier element that describes the conditions under which a discount is given. The qualifier element is always evaluated first.

  • filterItemsForTarget: A target element in a PMDL rule identifies objects to be discounted from a larger pool of all available objects of the same type. A target element is not a mandatory part of the PMDL rule. If the input environment does not match the qualifier element, the target element is not evaluated.

    findQualifyingItems,which returns a list of CommerceItems, is the only Qualifier method that returns a set of objects rather than a single object. A PMDL rule that does not deal with CommerceItems does not need to contain a target element because it has no need to select objects from a larger pool.

    For example, there’s no need for a rule that discounts an order to have a target element, because only one Order object can be discounted. However, PMDL rules do support the use of target elements to identify Order objects from a pool of available Orders. If, in the future, ATG Commerce supports discounting multiple orders at the same time, new filterOrdersForQualfiier and filterItemsForTarget methods will have to be added to the Qualifier class.

The following example shows how the filterItemsForQualifier and filterOrdersForTarget methods work. This example uses the rule “for next 1 item that is blue, discount up to 1 item that is green.”

The filterItemsForQualifier method is invoked first. By default, this method uses the following criteria to remove items from the environment. This prevents the methods from helping to satisfy the constraints specified in the “qualifier rule” portion of the input PMDL rule:

  • If an item’s price is zero, the item is removed.

  • If an item has already acted as a qualifier, the item is removed.

  • If an item has already received the discount that’s currently being evaluated, the item is removed.

After items are filtered out of the environment, the evaluateQualifier method is invoked. evaluateQualifier selects one blue item from the environment that acts as a qualifier. (For more information on these methods, refer to the next section, Replacing the Way a PMDL Rule Is Evaluated.)

If the qualifier is satisfied, the system invokes the target, if there is one, to determine which objects among all those available should receive the discount that is enabled by the one blue item. ATG Commerce currently performs this selection for CommerceItems only.

Before the target element is evaluated, the filterItemsForTarget method must be invoked. The filterItemsForTarget method uses the following criteria to remove items from the environment against which the target is compared:

  • If an item already acted as a qualifier, the item is removed.

  • If an item already received the discount that is currently being evaluated, the item is removed.

After the filterItemsForTarget method is invoked, the evaluateTarget method is called. This method returns a set of items that can receive the discount because they satisfy the target element of the rule.

You can change the criteria by which items are filtered out of the environment before a rule is evaluated. For example, your filter could allow items with a price of zero to act as qualifiers for a rule. You could rewrite the filterItemsForQualifier method to remove that restriction.

 
loading table of contents...