The existing Qualifier doFilters() method evaluates items in the qualifier and target rules. The method uses the Qualifier service’s filtering methods to disqualify items before comparing them 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 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 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 items from helping to satisfy the constraints specified in the “qualifier” portion of the input PMDL rule:

After items are filtered out of the environment, the evaluateQualifier method is invoked. evaluateQualifier selects one blue item that acts as a qualifier from the environment. (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 evaluates the offer, if there is one, to determine which objects among all those available should receive the discount that is enabled by the one blue item. Oracle ATG Web 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 the item price is zero, negative, or less than the promotion price

  • If the item is on sale

  • If an item already acted as a qualifier

  • If an item already received the discount that is currently being evaluated, or any other discount

If the item meets any of those criteria, 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, or write your own filter component using the atg.commerce.pricing.PromotionQualifyingFilter interface.