When the current price of a product is accessed in the storefront via its price model, a price lookup is performed. The high-level steps of this price lookup are:
- Get all price books applicable in the context of the current site, time, session, customer, source code.
- Identify all prices in the applicable price books and for a requested quantity.
- Calculate the best-price of all identified prices. The best-price is the lowest price.
Identify applicable price books
- If any price books are explicitly registered in the session (see pipelet SetApplicablePriceBooks), use these price books and their direct parents for price lookup. Ignore all inactive price books, price books not valid at the current time, and price books with a currency other than the session currency.
- If a valid source code is registered with the current session, get all price books assigned to the source code and their parent price books. Ignore all inactive price books, price books not valid at the current time, and price books with a currency other than the session currency.
- Get all price books assigned to site and their parent price books. Ignore all inactive price books, price books not valid at the current time, and price books with a currency other than the session currency.
- Get all price definitions for the product from all applicable price books. Ignore price definitions not valid at the current time.
- Convert any percentage price definition into a monetary amount. As the base price for this calculation, the minimum product price for the minimum order quantity of the product, including product options, is used.
- Compare all prices and identify the lowest (= best) price.
- Calculate best price for each defined price cut in the price table and return price table.
- If no applicable pricebooks for a variant is found, the price lookup gets the price books from the variant's master product
- A price books is also not applicable of the price definition for the variant in the price book is not valid at the current time.
Typically, in order to do a standard price lookup, it is only necessary to
call Product.getPriceModel().getPrice()
. However, Commerce Cloud
Digital also supports tiered prices, meaning that higher quantities receive
a lower price. In this case, the merchant typically wants to display a table
of price points on product detail pages. Therefore, the ProductPriceModel
provides the method getPriceTable() to retrieve a table of these prices.
If a merchant wants to know not only what the price of a given product is, but what price book the price was derived from, this class provides the method getPriceInfo(). This class also provides methods to lookup product prices in specific price books by name and quantity. See getPriceBookPrice(String).
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitly set as applicable in the current session.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If no price could be found, MONEY.NOT_AVAILABLE is returned.
This method is similar to getPrice()
but instead of just
returning the price value, it returns a ProductPriceInfo
which contains additional information such as the PriceBook which defined
the price and the percentage discount this price point represents.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If no price info could be found, null is returned.
ProductPriceInfo
(s), calculated based
on base price quantity 1.00. This will return an empty list if getPriceInfo() would return null, and if there is
only one price info in the collection it will be the same price info as getPriceInfo(). Two or more price infos
indicate that there are that many price books that meet the criteria for returning the price shown in the
storefront.The product sales price per unit is returned for the current session currency. Hence, the using this method is only useful in storefront processes.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitly set as applicable in the current session.
If no price could be found, MONEY.N_A is returned.
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
Usually, the product price table is printed on product detail pages in the storefront.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
All other methods of this class are based on the information in the product price table.
ProductPriceInfo
(s), calculated based on base price quantity 1.00.Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitly set as applicable in the current session.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If no price could be found, MONEY.NOT_AVAILABLE is returned.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitly set as applicable in the current session.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If passed order quantity < 1 (and greater than zero), price for quantity 1 is returned.
If no price could be found, MONEY.NOT_AVAILABLE is returned.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
Money.NOT_AVAILABLE will be returned in any of the following cases:
- priceBookID is null or does not identify a valid price book.
- The price book has no price for the product.
- None of the prices for the product in the price book is currently active.
- The currently active price entry is a percentage.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
Money.NOT_AVAILABLE will be returned in any of the following cases:
- priceBookID is null or does not identify a valid price book.
- quantity is null.
- The price book has no price for the product.
- None of the prices for the product in the price book is currently active.
- The currently active price entry is a percentage.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
Money.NOT_AVAILABLE will be returned in any of the following cases:
- The priceBookID does not identify a valid price book.
- The price book has no price for the product.
- None of the prices for the product in the price book is currently active.
- The currently active price entry is a percentage.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
Money.NOT_AVAILABLE will be returned in any of the following cases:
- The priceBookID does not identify a valid price book.
- The price book has no price for the product.
- None of the prices for the product in the price book is currently active.
- The currently active price entry is a percentage.
This method is similar to getPrice()
but instead of just
returning the price value, it returns a ProductPriceInfo
which contains additional information such as the PriceBook which defined
the price and the percentage discount this price point represents.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If no price info could be found, null is returned.
This method is similar to getPrice(Quantity)
but instead of
just returning the price value, it returns a
ProductPriceInfo
which contains additional information such
as the PriceBook which defined the price and the percentage discount this
price point represents.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
If no price info could be found, null is returned.
ProductPriceInfo
(s), calculated based
on base price quantity 1.00. This will return an empty list if getPriceInfo() would return null, and if there is
only one price info in the collection it will be the same price info as getPriceInfo(). Two or more price infos
indicate that there are that many price books that meet the criteria for returning the price shown in the
storefront.The product sales price per unit is returned for the current session currency. Hence, the using this method is only useful in storefront processes.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitly set as applicable in the current session.
If no price could be found, MONEY.N_A is returned.
The product sales price per unit is returned for the current session currency. Hence, the using this method is only useful in storefront processes.
The price lookup is based on the configuration of price books. It depends on various settings, such as which price books are active, or explicitely set as applicable in the current session.
If no price could be found, MONEY.N_A is returned.
Usually, the product price table is printed on product detail pages in the storefront.
If the product represented by this model is an option product, option prices will be added to the price book price if the price model was initialized with an option model.
All other methods of this class are based on the information in the product price table.
Warning: If the product represented by this model is a master product with numerous variants, this method can be very expensive and should be avoided.