Background calculators triggered by checkout API calls
Key Takeaway
Checkout API calls trigger the calculators, and the client must wait for 200 OK before sending the next call.
When a storefront calls the Commerce Checkout APIs, Salesforce automatically runs background calculators for the cart. Together they compute pricing, promotions, inventory, shipping, and tax. You never call the calculators directly. Which calculators run depends on the API call and the fields in its payload. The calculators work in the background, so the API uses status codes to tell the client when the results are ready.
What Start Checkout does
Start Checkout (PUT /commerce/webstores/{webstoreId}/checkouts) requires cartId. The resource accepts both POST and PUT, but Salesforce recommends PUT.
Start Checkout first checks whether the cart already has an active checkout session. If it finds one, it returns that session. Start Checkout creates a new session and returns the new checkoutId only when none exists.
Start Checkout always runs the pricing, promotions, and inventory calculators. Start Checkout also runs the shipping and tax calculators, but only if a delivery address is available. A delivery address can be available at checkout start in three ways:
- The request includes
deliveryAddressInput. A guest user also supplies an address this way. - The request sets
shouldUseDefaultAddressto true, so the system uses the Contact Point Address or Profile address. - A registered user has a saved shipping address.
When the address comes from deliveryAddressInput or shouldUseDefaultAddress, the system validates the address and applies it to the CartDeliveryGroup object.