The Salesforce B2C Commerce API dw.catalog.ProductPriceModel scripting class enables
you to retrieve product prices in the storefront. Often products can have multiple prices
assigned. B2C Commerce uses a set of business rules to determine which price is relevant at a
given time.
The Salesforce B2C Commerce API
dw.catalog.ProductPriceModel
scripting class enables you to retrieve product
prices in the storefront. Often products can have multiple prices assigned. B2C Commerce uses a
set of business rules to determine which price is relevant at a given time. In general, B2C
Commerce, based on price lookup rules, determines the best price (lowest price) for a
requested quantity and shows it in the storefront.
Price lookup rules
- Changes entered programmatically through APIs, such as script or OCAPI, that aren’t
represented by promotions in the system, apply before changes made through Business
Manager.
- If you use the
SetApplicablePriceBooks
pipelet
to register a price book, the lookup calculates the best price from those price books and the
price book which those price books are based on. The price books are used only if they exist
and are activated within the activation dates and in the site currency. No other price books
are considered. The price books registered by the pipelet must be activated, but don't need to
be assigned to the site.
- If no price book is explicitly registered, the lookup considers
all active price books assigned to the site. It only considers price books that are in effect
at the current time and for the current site currency and have prices for the quantity
specified. It then takes the best price from all prices for the specified quantity.
- After determining the set of applicable price books by one of
these mechanisms, B2C Commerce determines the lowest price for the current product and
quantity within this set. B2C Commerce looks at all price tables for the current product
within these price books. If a price book doesn't define a price table for the current
product, it isn't considered. A price table must define a price for a threshold less than or
equal to the requested quantity or it isn't considered. If the current time doesn't fall
within the activation dates of a price table, that price table isn't considered.
- A single price book can define multiple price tables for the current product. However,
only one of the price tables is considered active, and the rest are not considered. In this
case, the active price table is the one that defines a time period containing the current time
and has the most recent start date. For example, a merchant defines two price tables for each
pair of winter boots. One has dates from October 1, 2015 to February 15, 2016, reflecting
in-season prices. The other has dates from February 16, 2010 to September 30, 2010, reflecting
off-season prices. On November 24, 2015, the first price table would be active, while on March
20, 2016, the second price table would be active.
- In this way, zero or one price tables are considered from each
applicable price book. B2C Commerce takes the best active price from these price tables
for the specified quantity. If there is no price for the specified quantity in these price
tables, then NA is returned.
- If no applicable price books for a variation product are found, the system falls back to
the price for the base product.
These rules represent how prices are retrieved through the scripting
API. Product prices are also relevant when a search is performed in the storefront. For example,
B2C Commerce lets you refine searches by price. For performance reasons, B2C Commerce does not
directly access prices that are stored in the database to provide this refinement capability.
Instead, it uses prices that are stored in the product search index when the index is built.
It's possible, therefore, for these prices to get out of synch (though they generally remain
consistent).
Adequate information is encoded in the product index. B2C Commerce
follows the same lookup rules regarding applicable price books, price activation dates, and
multiple price tables for a given product. Sometimes, you must rebuild the product index so that
the prices used by B2C Commerce are consistent with the prices that appear on product detail
pages.