Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Cart Item entry
How-to guide

Configure cart calculation for Cart Items

You do not create Cart Items directly; the storefront creates them when a shopper adds products. What you do configure is the Cart Calculate API, which is the framework that prices, promotes, checks inventory, and taxes each Cart Item. Here is how to set up custom cart calculation in a B2B or D2C store.

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

You do not create Cart Items directly; the storefront creates them when a shopper adds products. What you do configure is the Cart Calculate API, which is the framework that prices, promotes, checks inventory, and taxes each Cart Item. Here is how to set up custom cart calculation in a B2B or D2C store.

  1. Decide which calculators you need

    The Cart Calculate API ships Pricing, Promotions, Inventory, Shipping, and Taxes calculators. Confirm which standard ones meet your needs and where you require a custom integration, such as an external tax engine or a third-party inventory source.

  2. Write an orchestrator

    Create an Apex class that extends CartExtension.CartCalculate and override the calculate method. The orchestrator controls which calculators run and in what sequence when the cart changes.

  3. Register the extension point

    Register your orchestrator for the Commerce_Domain_Cart_Calculate extension point so the platform invokes it on cart updates. Without registration, the default calculation runs instead.

  4. Plug in custom calculators

    For a custom tax or inventory integration, implement the matching calculator and have your orchestrator call it. The calculator reads the Cart Items, computes its result, and writes values back to the cart.

  5. Test on representative carts

    Validate in a sandbox with carts that mix product and charge lines, multiple delivery groups, and stacked promotions. Confirm the totals and the Cart to Order mapping before you enable it in production.

Key options
Calculator phaseremember

Pricing, Promotions, and Inventory run during both cart and checkout; Shipping and Taxes run only at checkout by default.

Orchestrator classremember

Extend CartExtension.CartCalculate and override calculate to control calculator order and which ones execute.

Extension pointremember

Commerce_Domain_Cart_Calculate is the registration name the platform uses to find and invoke your orchestrator.

Inventory behaviourremember

Choose whether an out-of-stock Cart Item blocks checkout or is flagged for backorder, tuned per product type.

Gotchas
  • Shipping and Taxes do not run during the cart phase by default, so cart-stage totals exclude them until checkout.
  • A custom field only maps from Cart Item to OrderItem if the same API name exists on both Cart and Order (and OrderSummary).
  • Loading and saving the in-memory CartExtension.CartItem is done by Salesforce, not by your Apex; you read and adjust, the platform persists.
  • Stacked line-level and cart-level promotions can interact in surprising ways; test the combined discount on real carts.

See the full Cart Item entry

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