CartCheckoutSession state and checkout session flow actions
Key Takeaway
Use Checkout Session Action to get or create the session, then use Update Checkout Session Action to change its state. The update happens only when the session's current state matches expCurrentState.
A checkout session tracks a buyer's cart while it moves through checkout in Lightning B2B Commerce. The session is stored as a CartCheckoutSession record linked to a WebCart. Its State field records where checkout currently stands. Two B2B Commerce flow actions manage the session. Checkout Session Action starts or gets the session, and Update Checkout Session Action moves it safely from one state to the next. When you customize a checkout flow, you work with these actions and the session state they change.
The CartCheckoutSession record
CartCheckoutSession represents a checkout session used in Lightning B2B Commerce checkout. The object is available in API version 48.0 and later, and only when the B2B Commerce or D2C Commerce license is enabled.
Each checkout session is tied to a single cart through WebCartId, but one cart can have multiple checkout sessions. You can set WebCartId when you create the record, but you can't update it afterward.
| Field | What it holds |
|---|---|
State | The current state of the session, as a string |
NextState | The state the session moves to next, as a string |
BackgroundOperationId | The ID of the background operation in progress |
OrderId | The ID of the order created after the session goes from cart to order |
Three boolean flags describe the session, and all three default to false:
IsProcessingis true while checkout processing is in progress.IsErroris true when the session is in an error state.IsArchivedis true when checkout processing is archived.
Archiving can't be undone. After a session's IsArchived is set to true, the session can't be unarchived.
In API version 63.0 and later, LWR stores don't populate CartCheckoutSession.OrderReferenceNumber at checkout. They populate the InitialOrderReferenceNumber field on WebCart instead.