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
priceItems
method changes the price of input items. It first callsfindQualifyingItems
to get items whose prices need changing. It then callspriceQualifyingItems
to change their price.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 thefindQualifyingItems
method of the Qualifier.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
callspriceQualifyingItem
once for each input item to be priced.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 eachpriceDetailedItemPriceInfo
, discounting details until the total number of items to discount has been reached.The
priceDetailedItemPriceInfo
method modifies the price of adetailedItemPriceInfo
. It maintains the audit trail and marks the details that have acted as qualifiers. It callsfindAdjustedPrice
to find the new price of the details.The
findAdjustedPrice
method 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
findQualifyingItems
to 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
priceQualifyingItems
to change how a group ofItemPriceInfos
are adjusted.Override
priceQualifyingItem
to change how an individualItemPriceInfo
is adjusted.Override
priceDetailedItemPriceInfo
to change how aDetailedItemPriceInfo
within anItemPriceInfo
is adjusted.Override
findAdjustedPrice
to 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.)