This content has been marked as final. Show 5 replies
priceItem() or priceEachItem() -> These two method will price a commerce item as a single item. priceItems() method will price an item in such a way that price may vary depending up on the other commerce item in the context.
priceEachItem() prices the each item in the list in its own context (it will not consider the changes in the pricing due to other items).
priceItems() prices the items in the list in assumption that all these items are in the same pricing context (ex: all items are going in the same order).
Thus using priceItems() on items A and B, which are in such a way that adding item B to the order along with item A gives 10% discount of order, can be acheived.
It is given with another example in the API doc as well.
I have not used this. But to the extent I know, priceEachItem is mainly used to display the price of items while displaying the catalog whereas priceItems method is used to display the price of items in cart.
priceItems method takes order object also as a param so that it can consider all items in the order while pricing the items. priceEachItem or priceItem method does not require order object to be passed in.
Below are as in the documentation in http://docs.oracle.com/cd/E35318_02/Platform.10-1-1/ATGCommProgGuide/html/s0902itempricingengineinterface01.html:
An ItemPricingEngine can determine prices in three ways:
The priceItem method prices an item as a single item. It reviews any promotions that are passed in through a pPricingModels parameter.
The single item that is passed in is the only one available to satisfy the requirements of any promotion. For example, if the item passed in is “5 blue women’s shorts,” and there is a promotion for “Buy 7 or more blue shorts, get one pair free,” the promotion would not take effect. This call is mainly used for displaying item prices when a customer is browsing the catalog.
The priceEachItem method batch processes all the items that are passed in, but they are priced as if they were passed into PriceItem one at a time.
The priceItems method prices all input items all in the same context. To continue with the same example, the customer now puts “6 blue men’s shorts” in the shopping cart in addition to the “5 blue women’s shorts.” While the customer is just browsing the catalog, the “Buy 7 or more blue shorts, get one pair free” promotion is not factored in when displaying prices. Therefore, when the customer makes the decision to add the shorts to the shopping cart, the price shown is still full price for all the shorts. However, when the customer subsequently displays the contents of his or her cart, the promotion takes effect and shows that one pair of shorts is free.
The pricing context is defined by the method’s input parameters. In the case of priceItem, the context is as follows: the items to be priced, the promotions to factor, the profile of the user, the locale, and any additional parameters.
The context can be important because some promotions take effect only if the item appears in a pricing context with other items. For example, a certain promotion might give 10 percent off an order if the pricing context includes one shirt and one pair of pants. The items would only receive the discount if priced in the same context.