Use CpqCartDocument
The CpqCartDocument is a trimmed and flexible JSON structure that you can use in the CPQ on Core services. You can then use the output JSON to send responses to upper layer APIs such as the Digital Commerce APIs.
- Cart Field Management: Manage and update cart-level fields.
- Line Item Operations: Add, update, or remove items from the cart.
- Pricing Operations: Execute and manage pricing calculations.
- Attribute Management: Handle product or line item attributes.
- Promotion Handling: Apply and manage cart-level and item-level promotions.
- External Pricing Integration: Integrate with external systems for pricing data.
In Standard Cart APIs, the CpqCartDocument instance is passed through the input map.
This section provides examples of working with Cart fields, including performing updates on individual fields as well as handling multiple field changes in a single operation.
The setCartField can only update total-related fields associated with Usage Pricing or the Cost and Margin feature fields such as:
- vlocity_cmt__EffectiveOneTimeCostTotal__c
- vlocity_cmt__EffectiveRecurringCostTotal__c
- vlocity_cmt__RecurringMarginTotal__c
- vlocity_cmt__EffectiveUsageCostTotal__c
- vlocity_cmt__OneTimeMarginTotal__c
- vlocity_cmt__OrderMarginTotal__c
- vlocity_cmt__UsageMarginTotal__c
This section provides examples of managing cart line items, from retrieving all items in the cart to getting and setting multiple fields on an individual line item.
This section provides examples of cart-level pricing operations, including how to apply or clear externally provided prices and how to retrieve pricing variable maps for further processing.
This is the Standard Cart equivalent of the classic method used to retrieve the pricing variable map.
This section provides examples of how to work with attributes, including retrieving attribute definitions, updating attribute values, and managing referred attributes within the cart or its line items.
- The cartDocument object is not accessible in the pre- or post-hooks of cpqAppHandler.
- For migrated Standard Cart APIs, custom logic—such as validations or pricing—should rely on cartDocument rather than a list of line-item sObjects.
- Because not all APIs have migrated to the Standard Cart framework, custom implementations must accommodate both Classic and Standard Cart flows and switch dynamically based on context.
- In Standard Cart APIs, the CpqCartDocument contains only the bundles and line items affected by the current operation. As a result:
- Methods like getItemIds() or getAllItems() return only the impacted items, not the entire cart.
- Products or bundles not affected by the current transaction are excluded from the cart document.
- In Standard Cart APIs, cart data remains in-memory as a CpqCartDocument and is not persisted until the pricing step is completed. All cart objects stay in memory throughout the operation, and persistence occurs only after pricing has finished.