Cert++
Close

Retrieving product prices and applicable price books in script

Key Takeaway

To get both the storefront price and the price book that supplied it, call getPriceInfo() on the product's price model and read the price book from the returned ProductPriceInfo. That price book can be a parent price book that isn't assigned to the site.

In B2C Commerce, prices are not stored on the product itself. They live in price books. Script code gets a price by asking the product for its ProductPriceModel, which looks up the right price for the current site, session, time and currency. The PriceBookMgr class lets code read price books and choose which ones the price lookup uses. Picking the right method matters, because some methods return only an amount, some also name the price book, and some read a single price book.

Price books

Price books belong to the whole organization, so a price book only affects a storefront after it is assigned to a site. One site can have many price books. One price book can serve many sites.

A child price book can be "Based On" a parent price book. The child inherits all of the parent's prices and can override them.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.