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:
The
priceItemsmethod changes the price of input items. It first callsfindQualifyingItemsto get items whose prices need changing. It then callspriceQualifyingItemsto change their price.The
findQualifyingItemsmethod selects items to be discounted. It bases item selection on attributes of the input environment as represented by the method’s parameters. It calls thefindQualifyingItemsmethod of the Qualifier.The
priceQualifyingItemsmethod 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.priceQualifyingItemscallspriceQualifyingItemonce for each input item to be priced.The
priceQualifyingItemmethod 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.priceQualifyingItemcalls eachpriceDetailedItemPriceInfo, discounting details until the total number of items to discount has been reached.The
priceDetailedItemPriceInfomethod modifies the price of adetailedItemPriceInfo. It maintains the audit trail and marks the details that have acted as qualifiers. It callsfindAdjustedPriceto find the new price of the details.The
findAdjustedPricemethod produces a number that is the new price of aDetailedItemPriceInfo. 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.
Override
findQualifyingItemsto change the way the calculator finds the items to discount. You must override this method if you do not want to use the Qualifier service.Override
priceQualifyingItemsto change how a group ofItemPriceInfosare adjusted.Override
priceQualifyingItemto change how an individualItemPriceInfois adjusted.Override
priceDetailedItemPriceInfoto change how aDetailedItemPriceInfowithin anItemPriceInfois adjusted.Override
findAdjustedPriceto change how the calculator determines new prices.
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.)

