Update cart items

The shopping cart is where the information on the products chosen by the customer while browsing a store is gathered. This data may include item prices, shipping value, payment, and delivery methods, among others.

This guide will describe how to modify the quantity of an item in the cart or remove it by the API.

πŸ“˜

To remove all items from the cart at the same time, use the Remove all items endpoint.

Getting shopping cart information

The first step is to get the orderFormId of the shopping cart that you want to update cart items information. For more information, access the Get cart information by ID guide.

Updating shopping cart items quantity

To update items in the shopping cart, you need to use the Update cart items endpoint. In this request, you must send the following information through the URL:

  • Path param: orderFormId value.
  • Query param: allowedOutdatedData. You can set up this query as false or true to define whether some cart information can be updated through the minicart.

See a URL example below:

https://accountname.environment.com.br/api/checkout/pub/orderForm/ede846222cd44046ba6c638442c3505a/items?allowedOutdatedData=paymentData

Additionally, you need to send the request body containing the index (item's position in the array or cart) and the new quantity value. See a request body example below:

{
     "orderItems": [
          {
               "quantity": 3,
               "index": "1"
          }
     ]
}

After sending the request, the endpoint will return the response body with the shopping cart information containing the new item quantity information.

...
"items": [
        {
            "uniqueId": "BAE0177A615A4EB1B261DDF3274076F8",
            "id": "5",
            "productId": "7",
            "productRefId": "",
            "refId": null,
            "ean": "978020137962",
            "name": "Ultra Moisturizing Milk Conditioner 100 ml",
            "skuName": "100 ml",
            "modalType": null,
            "parentItemIndex": null,
            "parentAssemblyBinding": null,
            "assemblies": [],
            "priceValidUntil": "2023-11-08T18:01:42Z",
            "tax": 0,
            "price": 4490,
            "listPrice": 4490,
            "manualPrice": null,
            "manualPriceAppliedBy": null,
            "sellingPrice": 448840,
            "rewardValue": 0,
            "isGift": false,
            "additionalInfo": {
                "dimension": null,
                "brandName": "VALDIE&CO",
                "brandId": "2000000",
                "offeringInfo": null,
                "offeringType": null,
                "offeringTypeId": null
            },
            "preSaleDate": null,
            "productCategoryIds": "/4/1/",
            "productCategories": {
                "1": "Treatments",
                "4": "Stylers"
            },
            "quantity": 3,
            "seller": "cosmetics1",
            "sellerChain": [
                "cosmetics1"
            ],
            "imageUrl": "http://cosmetics2.vteximg.com.br/arquivos/ids/155403-55-55/Ultra-Moisturizing-Milk-Conditioner.jpg?v=637109315995300000",
            "detailUrl": "/ultra-moisturizing-milk-conditioner/p",
            "components": [],
            "bundleItems": [],
            "attachments": [],
            "attachmentOfferings": [],
            "offerings": [],
            "priceTags": [
                {
                    "name": "[email protected]#e5b461db-58da-46a0-87b9-fbab27c5caad",
                    "value": -480,
                    "rawValue": -4.8,
                    "isPercentual": false,
                    "identifier": "0e45a4e3-6084-4bf9-bff7-0fe8403699fc",
                    "owner": "cosmetics2"
                }
            ],
            "availability": "cannotBeDelivered",
            "measurementUnit": "mg",
            "unitMultiplier": 100.0000,
            "manufacturerCode": null,
            "priceDefinition": {
                "calculatedSellingPrice": 448840,
                "total": 1346520,
                "sellingPrices": [
                    {
                        "value": 448840,
                        "quantity": 3
                    }
                ]
            }
        },
...

πŸ“˜

For more information about the meaning of each of the fields available in the shopping cart, access the orderForm overview.

Removing shopping cart items

To remove an item from the cart you must use the same endpoint and parameters as in the previous section (Updating shopping cart items quantity). However, the quantity value to be sent in the request body must be 0. See a request body example below:

...
{
     "orderItems": [
          {
               "quantity": 0,
               "index": 1
          }
     ]
}
...

After sending the request, the endpoint will return the response body with the shopping cart information without the removed item.

Error codes

The following errors may appear as a message in the response body.

400 - Bad Request

  • Message error example (code ORD002): "Invalid order form". The orderFormId information is not valid.
{
    "fields": {},
    "error": {
        "code": "ORD002",
        "message": "Invalid order form",
        "exception": null
    },
    "operationId": "5d9f54e6-7db4-46d6-bca9-deeb278b8b98"
}
  • Message error example (code CHK0023): "Invalid quantity for the item". This message indicates that the quantity value (mandatory) has not been sent in the request body.
{
    "fields": {},
    "error": {
        "code": "CHK0023",
        "message": "Invalid quantity for item",
        "exception": null
    },
    "operationId": "5d9f54e6-7db4-46d6-bca9-deeb278b8b98"
}
  • Message error example (code CHK0041): "Invalid item index". This message indicates that the index used in the request does not exist or is incorrect.
{
    "fields": {},
    "error": {
        "code": "CHK0041",
        "message": "Invalid item index",
        "exception": null
    },
    "operationId": "5d9f54e6-7db4-46d6-bca9-deeb278b8b98"
}

404 - Not Found

  • Message error example: "The requested URL was not found on the server". Check that the URL data is correct.
<body>
    <h1>404 Not Found</h1>
    <p>The requested URL was not found on this server.</p>
</body>