Multi Edit Cart Line Items

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.

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.

Note

URI 

1/services/apexrest/{namespace}/v2/cpq/carts/{cart_ID}/items

HTTP Method 

PATCH

Apex Method 

multiEditCartItems

Apex Remote Service 

1CpqAppHandler

Request Parameters 

ParameterDescription
namespacevlocity_cmt
cart_IDThe unique ID of the cart, which is the ID of the opportunity, quote, or order

Query Parameters 

ParameterDescription
priceExecute the pricing service and price the affected items.
validateExecute the context rules and advance rules for the affected items.

Example Request 

1PATCH
2/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartid}/items?price=true&validate=true
3
4Request Body:
5{
6  "items": [
7    {
8      "rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
9      "assetReferenceId": "c548e1d2-8078-4eca-8a79-916ba79b2595",
10      "fields": {
11        "<field_api_name1>": "value1",
12        "<field_api_name2>": "value2",
13        "quantity": "value3",
14        ...
15      },
16      "attributes": {
17        "<attributeCode>" : "userValue",
18        "<attribute2Code>" : ["userValue2", "userValue3"],
19        ...
20      }
21    }
22  ]
23}

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.

1{
2   "items": [
3      {
4        "rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
5        "assetReferenceId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
6        "fields": {
7           "Quantity": 5
8      }
9    },
10 {
11        "rootItemId": "f6e846b1-2a7e-4d8a-8de5-50e5f986ca4e",
12        "assetReferenceId": "c548e1d2-8078-4eca-8a79-916ba79b2595",
13        "fields": {
14           "Quantity": 7
15      }
16    }
17  ]
18}

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

1{
2    "status":"success",
3    "message":"Line Items are updated successfully.",
4    "code":"200.MultiEditCartItems.000"
5}

Failure Scenario

1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.002",
4  "message" : "Invalid cartId passed in request URL."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.011",
4  "message" : "Set CPQ Configuration UseAssetReferenceIdForParentAndRoot to true for MultiEditCartItem API to work."
5}
1{
2  "status" : "error",
3  "code" : "413.MultiEditCartItems.001",
4  "message" : "Guardrail Exception : Limit for MultiEditCartItem API is : 20 per API call."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.010",
4  "message" : "Invalid Asset Ref Ids: [Id] passed in Input."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.006",
4  "message" : "Disconnected line item cannot be edited."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.015",
4  "message" : "No Fields or Attributes to Edit for Asser Reference Ids : [ID]."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.014",
4  "message" : "Duplicate Line Items for assetRefIds : [ID]."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.001",
4  "message" : "Field passed [FieldName] is invalid."
5}
1{
2  "status" : "error",
3  "code" : "400.MultiEditCartItems.002",
4  "message" : "Field passed [FieldName] is not editable."
5}