Skip to content
Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Cart entry
How-to guide

How to configure cart calculation in B2B and D2C Commerce

The Cart itself is created automatically when a buyer shops, so there is no manual Cart record to add. What an admin or developer configures is the cart calculation behavior through the Cart Calculate API. These steps describe enabling and customizing that calculation for a B2B or D2C store.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

The Cart itself is created automatically when a buyer shops, so there is no manual Cart record to add. What an admin or developer configures is the cart calculation behavior through the Cart Calculate API. These steps describe enabling and customizing that calculation for a B2B or D2C store.

  1. Confirm Cart Calculate API is active

    For newer webstores the Cart Calculate API is enabled by default. In Commerce setup for your store, verify that cart calculation is using the CCA framework so that pricing, promotions, inventory, shipping, and tax run through orchestrators and calculators.

  2. Set up pricing and promotions

    Associate the right price book with the store so the pricing calculator has list and negotiated prices to read. Build your discounts in the promotion setup so the promotions calculator can apply cart-level and line-level adjustments in the correct sequence.

  3. Integrate tax and shipping services

    If you use an external tax engine, extend the Commerce_Domain_Tax_Service base class to call it from the Taxes calculator. Configure shipping so the shipping and post-shipping steps can calculate delivery cost per CartDeliveryGroup at checkout.

  4. Add a custom orchestrator only if needed

    When the default calculator order does not fit, write a class that extends CartExtension.CartCalculate and register it at the Commerce_Domain_Cart_Calculate extension point. Use it to reorder or skip calculators, then test the resulting totals end to end before going live.

Pricing calculatorremember

Runs first and sets line prices; extensible through Commerce_Domain_Pricing_Service for custom contract pricing.

Promotions calculatorremember

Applies cart-level and line-level discounts after pricing; model offers in promotion setup.

Inventory calculatorremember

Checks availability for cart and checkout; extensible through Commerce_Domain_Inventory_Service.

Taxes calculatorremember

Runs at checkout and is extensible through Commerce_Domain_Tax_Service to integrate an external tax provider.

Gotchas
  • Running tax before promotions taxes a discount the buyer never pays and inflates the grand total.
  • There is no Abandoned status on WebCart; an abandoned cart is an Active cart identified by its last-modified age.
  • Prefer extending the calculator framework over writing triggers on WebCart or CartItem, which fights the calculation sequence.
  • A slow external tax or shipping call at checkout is felt directly by the waiting buyer, so handle timeouts gracefully.

See the full Cart entry

Cart includes the definition, worked example, deep dive, related terms, and a quiz.