Remove all items from cart

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 remove all items from a shopping cart by the API.

Getting and accessing shopping cart information

The first step is to get the orderFormId and access the shopping cart information that you want to remove the items from. To do so, access the Get cart information by ID guide.

See below an example of item details contained in a shopping cart:

...
"items": [
        {
            "uniqueId": "C6D260865A4B4609B494973D96790104",
            "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-10-11T16:31:28Z",
            "tax": 0,
            "price": 4490,
            "listPrice": 4490,
            "manualPrice": null,
            "manualPriceAppliedBy": null,
            "sellingPrice": 448509,
            "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": 1,
            "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]#5aeb71dd-f6dd-4a2d-a624-d635f20e7cd0",
                    "value": -491,
                    "rawValue": -4.91,
                    "isPercentual": false,
                    "identifier": "0e45a4e3-6084-4bf9-bff7-0fe8403699fc",
                    "owner": "cosmetics2"
                }
            ],
            "availability": "available",
            "measurementUnit": "mg",
            "unitMultiplier": 100.0000,
            "manufacturerCode": null,
            "priceDefinition": {
                "calculatedSellingPrice": 448509,
                "total": 448509,
                "sellingPrices": [
                    {
                        "value": 448509,
                        "quantity": 1
                    }
                ]
            }
        },
  ...

📘

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

Removing all items from the shopping cart

To remove all items from the shopping cart, you need to use the Remove all items endpoint. In this request, the ordeFormId of the shopping cart must be sent through the URL request, as shown by the example below:

https://{accountname}.{environment.com.br}/api/checkout/pub/orderForm/{orderFormId}/items/removeAll

Additionally, you need to send the request body containing only two curly brackets, as shown below:

{}

After sending the request, the endpoint will return the response body with all item information removed from the shopping cart ("items" field empty).

...
"items": [],
...

Error codes

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

400 - Bad Request

  • Message error example (code ORD002): "Carrinho inválido" (Invalid Cart): this message indicates that the orderFormId used in the request does not exist or is incorrect.
{
    "fields": {},
    "error": {
        "code": "ORD002",
        "message": "Carrinho inválido",
        "exception": null
    },
    "operationId": "5d37a185-bfe6-4686-9d92-aac9482cc63d"
}
  • Message error example (code 001): "Bad Request": this message indicates that information other than {} was sent in the request body.
{
    "fields": {},
    "error": {
        "code": "001",
        "message": "Bad request",
        "exception": null
    },
    "operationId": "91b68251-1a60-4716-b846-c7c9c31fa565"
}

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>