This section describes the following ATG Commerce price holding classes:

AmountInfo

The atg.commerce.pricing.AmountInfo parent class represents price information about an object. In addition to the actual amount, it also contains information about how to interpret that amount. This class is the base for the ItemPriceInfo, OrderPriceInfo, TaxPriceInfo, and ShippingPriceInfo classes.

The AmountInfo class is designed only to hold data. The calculators perform all the computations and store the results.

The following list describes important properties in the AmountInfo class:

  • currencyCode: Indicates the currency of the price. For example, USD indicates that the price is in US dollars.

  • pricingAdjustments: Provides an audit trail of everything that happened to the AmountInfo up to this point. This information is useful if you need to determine how the object arrived at its current price (for example, for customer service requests).

  • amount: The raw number that represents the price.

  • discounted: Indicates whether this quantity of items has been discounted. If the flag is false, the items either have no price, or the list price.

  • amountIsFinal: Indicates if the amount is final. If true, then this price is final and will never be recalculated. AmountInfo includes a method called markAsFinal(). This method sets the amountIsFinal property and adds a PricingAdjustment to the amountInfo. The Tax, Order, and Shipping PricingEngines, and the ItemPricingEngine.priceItem check if the priceInfo for the object being priced has amountIsFinal=true. If it is set to true, that priceInfo is immediately returned.

ItemPriceInfo

The atg.commerce.pricing.ItemPriceInfo class contains the following properties, which are modified by the item pricing calculators and returned by the item pricing engines:

The ItemPriceInfo class contains information about the price of an item (a CommerceItem). It also contains detailed price information about how individual quantities of the CommerceItem were priced. For example, if an item’s quantity is 5, and 3 items received Discount A and the other two received Discount B, there would be two DetailedItemPriceInfo entries in currentPriceDetails:

The amount property of ItemPriceInfo (inherited from AmountInfo) should always equal the sum of the amounts of the DetailedItemPriceInfo entries in currentPriceDetails.

DetailedItemPriceInfo

This section describes DetailedItemPriceInfo objects. Information in this section includes how DetailedItemPriceInfo objects relate to each other and to their ItemPriceInfo.

The ItemPriceInfo object describes the price for an entire CommerceItem in an order. The amount property of the ItemPriceInfo is the final price for the given CommerceItem. If part of the quantity of the CommerceItem was discounted due to a promotion, this information is reflected in the ItemPriceInfo. For example, if the order contains 10 shirts at $10.00 each, and there was a promotion “Buy 9 shirts, get 1 free” then the amount property of the ItemPriceInfo would be $90.00. The PricingAdjustments in the ItemPriceInfo would contain one PricingAdjustment for the list price, and one for the promotion. For more information on the ItemPriceInfo object, see the ItemPriceInfo section.

The DetailedItemPriceInfo objects provide a much more detailed view of the price of the item. In the example above, there would be two DetailedItemPriceInfo objects:

  • DetailedItemPriceInfo object #1:

    • quantity: 9

    • amount: $90.00

    • PricingAdjustment: set to the list price.

  • DetailedItemPriceInfo object #2:

    • quantity: 1

    • amount: $0.00

    • PricingAdjustment: There would be two PricingAdjustments. One with the list price, and one with the promotion that caused the item to be free.

Another feature of DetailedItemPriceInfo is the range property. Instead of a detail referring to “5 items” it is more specific and refers to “the first 5 items” or “items 2-6”. This is used for two reasons:

  • To split the details of items in different shipping groups. There is a range property in ShippingGroupCommerceItemRelationship. DetailedItemPriceInfo objects cannot refer to items in more than one shipping group.

  • During qualification of a promotion (the process of determining if a particular promotion applies to the order) we need to know which items have been looked at and which items have already qualified a promotion. For more information, see the Qualifier Class section.

The following statements are true for all CommerceItem objects:

  • Each CommerceItem has exactly one ItemPriceInfo.

  • The price of a particular item (if there are 10 shirts, the first shirt, or the second shirt, etc.) is described by exactly one detail.

  • Each DetailedItemPriceInfo in the ItemPriceInfo describes the price of a quantity of items that are all priced in exactly the same way. (The same list price, the same sale price, and the same promotions.)

  • All the items described by a DetailedItemPriceInfo are in the same shipping group.

To make sure all of the above statements are true, each ItemPricingCalculator has the responsibility of manipulating the DetailedItemPriceInfos correctly.

The following sections describe how the three different types of item calculators interact with DetailedItemPriceInfos:

Using List Price Calculators with DetailedItemPriceInfo Objects

The list price calculators are responsible for calculating the price based on the list price. They can usually look up a list price and multiply it by the quantity. If the entire quantity of the item is being shipped to the same place, there will only need to be one DetailedItemPriceInfo. The logic for making sure that each detail only refers to items in one shipping group is contained in this method: pricingTools.detailedItemPriceTools.createInitialDetailedItemPriceInfos

This method takes the following parameters:

These parameters are the only parameters required to perform list pricing and bulk pricing. The entire quantity gets the same price. To facilitate tiered pricing, there is another version of this method that also takes a Range argument. This means that new details will only be created for the given range. In this case, the TotalPrice is the price for the range as opposed to the entire CommerceItem. The ItemTieredPriceCalculator will call this method once per tier.

This method will only modify the DetailedItemPriceInfo objects. It is the responsibility of the caller to update the ItemPriceInfo.

Using Sale Price Calculators with DetailedItemPriceInfo Objects

The calculators responsible for calculating the sale price usually change the price of the entire quantity. The calculator retrieves the sale price, subtracts the list price, and then modifies the amount accordingly.

This functionality is contained in a centralized method: pricingTools.detailedItemPriceTools.assignSalePriceToDetails. The assignSalePriceToDetails method takes the following parameters:

The assignSalePriceToDetails method walks through each detail and adjusts the amount accordingly. There is no reason to create any new details. This method will only modify the DetailedItemPriceInfo objects. It is the responsibility of the caller to update the ItemPriceInfo objects.

One sale calculator that does not use this method is the ItemSalesTieredPriceCalculator. This calculator splits the details since each quantity of the item will not necessarily get the same unit sale price. Therefore it usually splits each detail to maintain the property that each item in a detail was priced in exactly the same way (this includes having the same unit sale price).

Using Item Discount Calculators with DetailedItemPriceInfo Objects

The calculators that are responsible for discounting the price based on a promotion usually only adjust the price for some subset of the quantity. Therefore, the ItemDiscountCalculator frequently splits details. What our implementation of the ItemDiscountCalculator does is figure out the range that is undiscounted and figure out the range that is discounted. It creates a new DetailedItemPriceInfo for the undiscounted portion and set its quantity to the number of undiscounted items. It modifies the current detail to be discounted and changes its price. Then, with each detail, it calls pricingTools.detailedItemPriceTools.splitDetailsAccordingtoRanges.

This method takes the following parameters:

This method takes the current detail and creates enough new details so that there is one per Range that is passed in. All the details are returned.

OrderPriceInfo

The atg.commerce.pricing.OrderPriceInfo class contains information about the price of an order. The OrderPriceInfo class contains the following properties, which are modified by order pricing calculators and returned by order pricing engines:

ShippingPriceInfo

The atg.commerce.pricing.ShippingPriceInfo class contains information about the price of a ShippingGroup. It contains the following property, which is modified by shipping pricing calculators and returned by shipping pricing engines:

TaxPriceInfo

The atg.commerce.pricing.TaxPriceInfo class represents tax price information. It contains the following properties, which are modified by tax pricing calculators and returned by tax pricing engines.

 
loading table of contents...