This section explains how to create a new implementation of a pricing calculator interface and how to use the new calculator.

Creating a New Pricing Calculator

Use the following interfaces to create a new pricing calculator that fits into the existing Oracle ATG Web Commerce pricing architecture:

Implement the interface that corresponds to the type of price you want to calculate. For example, if you want to make calculations on order prices, implement OrderPricingCalculator.

In the following example, assume you have identified a need for a calculator that sets an item’s price to half its current price plus one. The existing Oracle ATG Web Commerce tools include an ItemDiscountCalculator that discounts items. It can give a percent off a price or an amount off, or it can set an item’s price to a fixed amount. None of these three options, however, easily gives a “half off plus one” discount. To achieve that result, you would have to use two different discounts: one to give 50 percent off, and another to add 1 to that total. A better alternative would be to create a new calculator that discounts an item’s price to half its current price plus one.

To create the new calculator, you create a class called HalfPlusOneItemDiscountCalculator that implements the ItemPricingCalculator interface. The HalfPlusOneDiscountCalculator is an example of a discount calculator that leverages existing Oracle ATG Web Commerce functionality to perform its own unique task.

In addition to modifying an item’s price, the Commerce item discount calculators also do the following:

The HalfPlusOneDiscountCalculator leverages all the above functionality from the ItemDiscountCalculator. The only method it overrides is the findAdjustedPrice method, which modifies an input DetailedItemPriceInfo to be the right amount. In this case, the class modifies the price of the detail to half its current price plus one.

Using a New Pricing Calculator

After you have created a new calculator, you must associate it with its corresponding pricing engine. You can do this in one of the following ways:

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices