Loading
Prepare for Email to Become the Default Login ExperienceRead More
Salesforce B2B Commerce
Adding an Expression to a Commerce Component

Adding an Expression to a Commerce Component

Enter expressions into any LWR component on a page with data providers. In some components, you can select an expression from a provided list. You can also combine expressions or add values.

Required Editions

View supported editions.

Which Salesforce Commerce Product Do I Have?

B2B Store Pages with Data Providers

The expressions that you can use in a component depend on which data providers are available on the page. Pages with Commerce-related data provider components are:

  • Cart page—Access cart details and totals
  • Checkout page—Access checkout details
  • Order Summary page—Access order data
  • Product page—Access product data
  • Search page—Access search data

Other places where data providers are available include:

  • Record Detail page—Access record data for supported objects through expressions, such as {!Item.recordField}. See All Supported Objects.
  • Any page—Access CMS content through the Banner, Card, Overlap, and Tile components. See Use Expressions in LWR Sites.

Built-In Expressions

If a component includes built-in expressions, the Inherited Content field specifies which data is available. The component also includes a field where you can enter text or select an available expression.

For example, in this text block on a Cart page, the inherited content is Commerce Cart Data.

Text block component with Commerce Cart Data inherited content. Text or Expression dropdown shows Show ID and Account ID expressions.

The available expressions shown pull in the store ID and the account ID associated with the cart.

The components with properties that indicate the presence of a data provider are: Banner, Button, Card, Grid, HTML Editor, Image, Overlap, Rich Content Editor, Text Block, Tile, and Video.

Example
Example
  • Show an offer that’s based on whether the unit price is more than $100.

    {!Product.Pricing.unitPrice > 100}—Returns true or false depending on whether the unit price is larger than 100.

  • Create an offer based on whether the list price is less than the unit price.

    {!Product.Pricing.listPrice < Product.Pricing.unitPrice}—Returns true or false depending on whether the list price is smaller than the unit price.

  • Show special deals based on a product’s brand.

    {!Product.Details.fields.Name == 'someName'}—Returns true when the product name equals ‘someName’.

  • Highlight customer savings.

    {!+Order.totalAmount - (+Order.adjustmentAggregates.totalProductPromotionDistAmount)}—Returns the difference between the total amount and the promotion distribution amount.

  • Show a product count next to the heading in the Cart Summary component.

    Summary ({!Cart.Details.totalProductCount})—Returns “Summary (X),” where X is the number of products in the cart.

 
Loading
Salesforce Help | Article