Pricing and promotions
Learn how the Algolia cartridge for Salesforce B2C Commerce handles pricing and promotions, how to index price and promotion data, and how to display them on your storefront.
Prices and promotions in SFCC
Salesforce B2C Commerce (SFCC) manages pricing and promotions using price books and a promotions engine. The Algolia cartridge can index price and promotion data and display them on the storefront.
The cartridge supports two modes for fetching pricing and promotion data:
- Indexing prices and promotions: Price and promotion data is indexed in Algolia and fetched with search results. The pricing information reflects the data at the time of indexing.
- Lazy loading prices and promotions: Price and promotion data is fetched asynchronously from SFCC when search results are displayed, ensuring the most up-to-date information, including dynamic promotions.
Price books
Price books define the base prices of products. A price book is a collection of product price definitions for a specific currency. SFCC allows multiple price books, which you can assign to sites. Price books can be arranged in a hierarchy, allowing for price inheritance.
Promotions engine
The promotions engine lets you create promotional campaigns that offer discounts or special offers to users. Promotions can be available to specific users, coupons, or under certain conditions, such as user segments or session-based promotions like “Buy One Get One Free.” You need to manage these promotions with the SFCC promotions engine. Promotions can apply various types of discounts, including percentage off, fixed amount off, or free shipping.
Algolia displays product-level promotions in search results but not order-level or shipping-level promotions because they depend on the session context.
Index price and promotion data with the Algolia cartridge
The Algolia cartridge lets you index price and promotion data with jobs so you can display accurate pricing and promotional information in your search results.
Indexing capabilities
What you can index
- Sale prices from price books: Index the sale prices of products from the active price books.
- Promotional prices: Index promotional prices calculated from active promotions applicable to all users.
- Promotions: Include information about promotions that are active or will be active in the next 30 days, such as promotion IDs and prices.
The cartridge maps SFCC product attributes to Algolia record attributes:
price
: The base price of the product from the price book.promotionalPrice
: The lowest promotional price of the product from active promotions.promotions
: An object containing promotional prices and promotion IDs.pricebooks
: An object containing prices from different price books mapped by their IDs.
1
2
3
4
5
6
7
8
9
10
11
12
{
"price": "Sales price from price book",
"promotionalPrice": "Lowest active promotional price",
"promotions": {
"prices": ["Array of promotional prices"],
"ids": ["Array of promotion IDs"]
},
"pricebooks": {
"priceBookId1": "Price from price book 1",
"priceBookId2": "Price from price book 2"
}
}
Configure indexed attributes
To index promotions and promotional prices:
- Go to Merchant Tools > Algolia > Algolia in Business Manager.
- In Additional Product Attributes, add
promotionalPrice
andpromotions
.
For more advanced configurations, use the productAttributesConfig.js
file in the int_algolia/cartridge/configuration/
directory to define how attributes are fetched and mapped.
For more details, see configurable attributes.
Display pricing and promotions on the storefront
Displaying pricing
The Algolia SFRA cartridge (int_algolia_sfra
) provides default templates and JavaScript code to display price and promotion information in search results with the following priority:
- Display of promotional prices: If a product has a promotional price, the original price displays with a strike-through, and the promotional price appears nearby.
- Display of list price: If a product has a list price, the list price displays with a strike-through, and the sales price appears near it.
- Display of sale price: The sale price is displayed as the default price.
Displaying promotions
The cartridge displays promotions that are active and applicable to the product:
- Price promotions: Promotions affecting the product’s price display as promotional prices.
- Call-out messages: Promotional messages like “20% off” or “Buy One Get One Free” appear on product tiles.
If a product is associated with an active promotion that has a call-out message, the message displays on the product tile as a badge or label.
These call-out messages are not indexed but are retrieved from SFCC using the promotion ID and injected in the
#algolia-activePromos
HTML element.
When the page loads, the cartridge calculates which promotions are active for each user and injects them into the search results. Then, the JavaScript code displays the prices and call-out messages accordingly.
Enable prices lazy loading
To enable prices lazy loading:
- Go to Merchant Tools > Algolia > Algolia in Business Manager.
- Select Enable prices lazy loading.
When enabled, prices, and promotions are fetched from SFCC when search results are displayed. This ensures that the most current pricing and promotions are shown without needing to reindex. It also allows for dynamic and contextual promotions to be displayed accurately.
Limitations
- Sorting and faceting: Sorting and faceting on promotional prices and lazy loading are not supported. The sales price in the index is used for sorting and faceting.
Implement in SiteGenesis
and PWA Kit
- SiteGenesis: Promotions and Lazy Loading features are not supported in
SiteGenesis
. Customize the behavior similarly to SFRA by modifying the corresponding files. - PWA Kit: Promotions and Lazy Loading features are not supported in PWA Kit. You need to implement custom logic to fetch pricing or promotional prices from SFCC.
Additional considerations
- Performance implications: Enabling pricing lazy loading provides the most accurate and up-to-date pricing information, but it causes some extra load on the server and delay when fetching pricing information.
- Customization: You can customize how pricing and promotions are displayed by modifying the templates and JavaScript in the
int_algolia_sfra
cartridge. For example, you can change the styling of price displays or how call-out messages are presented.