An ItemPriceCalculator
class maintains all the functionality common to all the pricing schemes. The ItemPriceCalculator
has the following important properties:
PriceListManager
: holds the reference toPriceListManager
PricingSchemeNames
: holds the key/Value pair for each allowed pricing scheme and its corresponding Calculator.For example:
listPrice
corresponds to thePriceListsListCalculator
bulkPrice
corresponds to thePriceListsBulkCalculator
tieredPrice
corresponds to thePriceListsTieredCalculator
Also, see the Using Price Lists in Combination with SKU-Based Pricing section for properties related to that capability.
The major public API exposed by this class includes:
getPricingScheme
: returns the pricing scheme for theCommerceItem
priceItem
: examines the allowedPricingSchemeNames
HashMap
. When a match is found, it will call the corresponding Calculator’spriceItem
method. Otherwise, an exception is thrown to indicate that the pricing scheme is not found.
Three sub-calculators correspond to the three different pricing schemes. The three different schemes are calculating the list price of an item, calculating the price of an item using bulk pricing, and calculating the price of an item using tiered pricing. For more information on bulk and tiered pricing, see the Using Price Lists section.
All of these calculators implement the ItemSchemePriceCalculator
, which only has a priceItem
method.
ItemListPriceCalculator
: Calls thegetPrice
method from thePriceListManager
to retrieve the list price of theCommerceItem
. It then multiplies the price by the quantity returned by thegetQuantity
method ofCommerceItem
to get the total price. TheItemPriceInfo
will contain oneDetailedItemPriceInfo
for eachShippingGroupCommerceItemRelationship
in theCommerceItem
. This is because of theRange
property in bothShipItemRels
andDetailedItemPriceInfos
.ItemBulkPriceCalculator
: Calls thegetPrice
method from thePriceListManager
to retrieve the complex price for theCommerceItem
. It will check each price level of that complex price based on the quantity of theCommerceItem
to decide the correct unit price for the item. TheItemPriceInfo
will contain oneDetailedItemPriceInfo
for eachShippingGroupCommerceItemRelationship
.ItemTierPriceCalculator
: Calls thegetPrice
method from thePriceListManager
to retrieve the complex price for theCommerceItem
. It will check each price level of that complex price to decide which unit price is used for each tier. TheItemPriceInfo
will might severalDetailedItemPriceInfos
to reflect different unit prices for each tier.
Using ItemPriceInfo with Price Lists
One ItemPriceInfo
class fits three different pricing schemes. Each calculator uses a different description for the PricingAdjustment
added to the ItemPriceInfo
.
The priceList
property of ItemPriceInfo
is set to the priceList
that was actually used to calculate it. This is nullable since other calculators other than those mentioned here will not set this. The ItemPriceCalculator
is responsible for setting this value.