Cert++
Close

Pricing reference implementation for cart items

Key Takeaway

When the Cart Calculate API is on, register custom pricing Apex as an Extension with a pricing extension point. Extend the pricing service, not only the pricing calculator, if Product Detail Pages (PDPs) need the same prices.

Cart item pricing sets the price of each product in a buyer's cart. Salesforce recalculates those prices when the cart changes or checkout starts. How you customize pricing depends on whether your store uses the Cart Calculate API. If it does, you extend the pricing calculator or the pricing service in Apex and register your class at an extension point. Stores that don't use the Cart Calculate API, such as Aura stores, use a price integration instead.

How pricing fits into the Cart Calculate API

The Cart Calculate API (CCA) splits cart and checkout math into three levels:

  • Orchestrators decide which calculators run and when.
  • Calculators do cart calculations such as pricing, promotions, inventory, shipping and tax.
  • Services do specific calculations that can reach beyond the cart.

Pricing is calculator number 1 in the default order, ahead of promotions, inventory, shipping, postShipping and taxes. The pricing calculator runs for both cart and checkout.

The default invocation logic checks pricing for errors. If pricing produces a cart validation output of type CartExtension.CartValidationOutputTypeEnum.PRICING, the orchestrator returns, so promotions and the later calculators don't run.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Code implementations against the 4 crucial reference implementations used in checkout and payment interfaces with in-depth knowledge of all supported actions

0/23

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers. 757 members and growing.