You can extend any of the pricing calculators. The ItemDiscountCalculator can be extended to calculate different discounts. The other calculators, however, are only implementations of various pricing calculator interfaces. They can be extended, but there is not much functionality for the subclasses to leverage. Subclasses could re-implement the appropriate calculator interface just as easily.

In most cases, it is easier to replace calculators other than the ItemDiscountCalculator with other implementations of the interfaces rather than extending them. For example, the OrderDiscountCalculator is an implementation of OrderPricingCalculator and does not provide additional functionality in its implementation of that interface. Instead of extending OrderDiscountCalculator, you should re-implement OrderPricingCalculator.

Extending the ItemDiscountCalculator

The ItemDiscountCalculator can be extended to calculate different discounts. It provides a number of extension points.

The following list describes the order of calls in ItemDiscountCalculator:

  1. The priceItems method changes the price of input items. It first calls findQualifyingItems to get items whose prices need changing. It then calls priceQualifyingItems to change their price.

  2. The findQualifyingItems method selects items to be discounted. It bases item selection on attributes of the input environment as represented by the method’s parameters. It calls the findQualifyingItems method of the Qualifier.

  3. The priceQualifyingItems method modifies the prices of an input collection of items. It also verifies that the items’ audit trail is maintained and marks the items that acted as qualifiers for this discount calculation so that they cannot act as a qualifier for another discount. priceQualifyingItems calls priceQualifyingItem once for each input item to be priced.

  4. The priceQualifyingItem method modifies the price of the input item. It also verifies that the item’s audit trail is maintained and, if the item acted as a qualifier for this discount calculation, it marks the item so that it cannot act as a qualifier for another discount. priceQualifyingItem calls each priceDetailedItemPriceInfo, discounting details until the total number of items to discount has been reached.

  5. The priceDetailedItemPriceInfo method modifies the price of a detailedItemPriceInfo. It maintains the audit trail and marks the details that have acted as qualifiers. It calls findAdjustedPrice to find the new price of the details.

  6. The findAdjustedPrice method produces a number that is the new price of a DetailedItemPriceInfo. It examines the existing price and the input parameters, and it returns the new price.

You can override any of these methods to provide new functionality while leveraging the existing code.

For example, the ItemDiscountMultiplierCalculator extends existing ATG Commerce pricing functionality by overriding the findAdjustedPrice method. This calculator computes the difference between an item’s list price and its current price and multiplies that difference by a variable, N. (For more information about this calculator, see the description of the ItemDiscountMultiplierCalculator class.)

loading table of contents...