Multi Edit Cart Line Items API allows the user to update multiple items present in the cart in a single transaction. It could be to update all modified attributes and fields at once across line items.
note: This API follows an all or nothing approach such that either the changes made to all line items are applied to the cart or none are applied at all.
URI
/services/apexrest/{namespace}/v2/cpq/carts/{cart_ID}/items
HTTP Method
PATCH
Apex Method
multiEditCartItems
Apex Remote Service
CpqAppHandler
Request Parameters
| Parameter | Description |
|---|---|
namespace |
vlocity_cmt |
cart_ID |
The unique ID of the cart, which is the ID of the opportunity, quote, or order |
Query Parameters
| Parameter | Description |
|---|---|
price |
Execute the pricing service and price the affected items. |
validate |
Execute the context rules and advance rules for the affected items. |
Example Request
PATCH
/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartid}/items?price=true&validate=true
Request Body:
{
"items": [
{
"rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
"assetReferenceId": "c548e1d2-8078-4eca-8a79-916ba79b2595",
"fields": {
"<field_api_name1>": "value1",
"<field_api_name2>": "value2",
"quantity": "value3",
...
},
"attributes": {
"<attributeCode>" : "userValue",
"<attribute2Code>" : ["userValue2", "userValue3"],
...
}
}
]
}
Example putCartsItems Request
In order to update quantity for the multiple line item, it requires to update the Quantity fields under corresponding rootItemId and assetReferenceId for the line item as per above JSON format, and send a PATCH request for update.
{
"items": [
{
"rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
"assetReferenceId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
"fields": {
"Quantity": 5
}
},
{
"rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
"assetReferenceId": "c548e1d2-8078-4eca-8a79-916ba79b2595",
"fields": {
"Quantity": 7
}
}
]
}
Example Response
The API does not provide a complete response after each modification. It’s just success or failure. In order to fetch the updated cart info, customers are required to execute the getCartItems API further.
Success Scenario
{
"status":"success",
"message":"Line Items are updated successfully.",
"code":"200.MultiEditCartItems.000"
}
Failure Scenario
{
"status" : "error",
"code" : "400.MultiEditCartItems.002",
"message" : "Invalid cartId passed in request URL."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.011",
"message" : "Set CPQ Configuration UseAssetReferenceIdForParentAndRoot to true for MultiEditCartItem API to work."
}
{
"status" : "error",
"code" : "413.MultiEditCartItems.001",
"message" : "Guardrail Exception : Limit for MultiEditCartItem API is : 20 per API call."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.010",
"message" : "Invalid Asset Ref Ids: [Id] passed in Input."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.006",
"message" : "Disconnected line item cannot be edited."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.015",
"message" : "No Fields or Attributes to Edit for Asser Reference Ids : [ID]."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.014",
"message" : "Duplicate Line Items for assetRefIds : [ID]."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.001",
"message" : "Field passed [FieldName] is invalid."
}
{
"status" : "error",
"code" : "400.MultiEditCartItems.002",
"message" : "Field passed [FieldName] is not editable."
}