Add 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 add new items to a shopping cart by the API.

Getting shopping cart information

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

Adding items to the shopping cart

To add items to the shopping cart, you need to use the Add 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 must send the request body containing the following information about the new item to be added to the cart:

  • quantity
  • seller
  • id
  • index
  • price

πŸ“˜

price should be sent only in case you want to make a bulk price change.

See a request body example below:

{
     "orderItems": [
          {
               "quantity": 3,
               "seller": "cosmetics1",
               "id": "2005",
               "index": 0
          }
     ]
}

After sending the request, the endpoint will return the response body containing the shopping cart information including the new item added, as shown in the example below:

...
"items": [
        {
            "uniqueId": "D1E0949706A3441DA0386929FAB6E7E8",
            "id": "2005",
            "productId": "3",
            "productRefId": "",
            "refId": null,
            "ean": "978020137962",
            "name": "Weightless Waves Mild Lather Cleanser 50 ml",
            "skuName": "50 ml",
            "modalType": null,
            "parentItemIndex": null,
            "parentAssemblyBinding": null,
            "assemblies": [],
            "priceValidUntil": "2023-11-07T22:14:44Z",
            "tax": 0,
            "price": 3190,
            "listPrice": 3190,
            "manualPrice": null,
            "manualPriceAppliedBy": null,
            "sellingPrice": 3107,
            "rewardValue": 0,
            "isGift": false,
            "additionalInfo": {
                "dimension": null,
                "brandName": "VALDIE&CO",
                "brandId": "2000000",
                "offeringInfo": null,
                "offeringType": null,
                "offeringTypeId": null
            },
            "preSaleDate": null,
            "productCategoryIds": "/2/",
            "productCategories": {
                "2": "Computers"
            },
            "quantity": 3,
            "seller": "cosmetics1",
            "sellerChain": [
                "cosmetics1"
            ],
            "imageUrl": "http://cosmetics2.vteximg.com.br/arquivos/ids/155401-55-55/ID-001-MAIN.jpg?v=637109313796670000",
            "detailUrl": "/weightless-waves-mild-lather-cleanser/p",
            "components": [],
            "bundleItems": [],
            "attachments": [],
            "attachmentOfferings": [],
            "offerings": [],
            "priceTags": [
                {
                    "name": "[email protected]#ac2d3d37-5845-45a6-9254-191449d6f100",
                    "value": -416,
                    "rawValue": -4.160,
                    "isPercentual": false,
                    "identifier": "0e45a4e3-6084-4bf9-bff7-0fe8403699fc",
                    "owner": "cosmetics2"
                }
            ],
            "availability": "available",
            "measurementUnit": "un",
            "unitMultiplier": 1.0000,
            "manufacturerCode": null,
            "priceDefinition": {
                "calculatedSellingPrice": 3107,
                "total": 15534,
                "sellingPrices": [
                    {
                        "value": 3107,
                        "quantity": 4
                    },
                    {
                        "value": 3106,
                        "quantity": 1
                    }
                ]
            }
        },
...

πŸ“˜

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

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 CHK0024): "Invalid seller for item". This message indicates that the seller used in the request does not exist, is incorrect or has not been informed.
{
    "fields": {},
    "error": {
        "code": "CHK0024",
        "message": "Invalid seller for item",
        "exception": null
    },
    "operationId": "abe5d1b9-a85f-4f10-a3e8-f783082c5c3d"
}

403 - Forbidden

  • Message error example (code CHK003): "Access denied". This message indicates that it is not possible to make a bulk price change on this item.
{
    "fields": {},
    "error": {
        "code": "CHK003",
        "message": "Access denied",
        "exception": null
    },
    "operationId": "a6ea8b84-68d9-43a7-902e-846e8c5c05b6"
}

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>