Add Items to Cart
Add items to the cart along with any required child products that are specified in the request body. Compatibility and pricing rules are run against the cart.
You must use the fieldsToUpdate parameter to update any default line item value.
Add line items to cart replaces the OmniCPQServiceWrapper addProducts method.
This API supports the guest user enhancements that Salesforce introduced with the Winter ‘21 release. To encrypt and decrypt data for guest users, use the UserSecurity class with this API. See Guest User Technical Details.
For additional information, see UserSecurity Class and CPQ and Digital Commerce Changes for Guest Users.
When you add child items to the cart:
-
Specify a
parentRecordnode in the input request. -
In the
parentRecordnode, specify theproductHierarchyPathfield. -
If the immediate parent of the child item that you're adding is a virtual parent, then also include these fields:
-
The
Idfield in theparentRecordnode. Ensure that it's thePricebookEntryIdof the immediate virtual parent. -
The
parentIdfield in theitemsnode. Ensure that it's thelineItemIdof the immediate real parent.
-
In releases prior to CME Spring '20, the postCartsItems method supports the addition of one item at a time. If you must add multiple items, make multiple postCartsItems calls.
With CME Spring '20 and later releases, the itemId parameter supports multiple comma-separated values when adding root and child items via postCartsItems method calls if UOWMode is set to true.
Communication (vlocity_cmt)
For API parameter names and descriptions, see Cart-Based API Swagger Reference.
For the fieldsToUpdate attribute, ensure to configure Date and Time values as per locale configuration without the seconds value. For example, 2024/10/10 11:46 for the Japanese locale. See Supported Date and Time Formats (ICU).
| Response Format | JSON |
|---|---|
| Resource URL | /services/apexrest/{namespace}/v2/cpq/carts/{cart_ID}/items |
For more information about levelBasedApproach, see Configuring Cart Item Refresh Levels.
To use this API to pass child line items, you must also specify the Price Book Entry ID.
An entire result can be thousands of lines long. This example has been truncated.