Cart Products Array

Cart Products Data Structure

When working with carts through the Venddor API, the products array contains detailed information about each product item within the cart. This documentation explains the structure and properties of product objects in the cart.

Usage: The cart products array appears in cart responses and can be used to retrieve information about products currently in a customer's cart.

Field Definitions

Each product in the cart products array has the following fields:

Field name Description Available for methods Supported values
product_id A unique identifier for the product. This ID corresponds to the product in your catalog. GET integer
amount The quantity of this specific product in the cart. This value can be updated through the API. GET string
price The unit price of the product. This may differ from the catalog price if promotions or customer-specific pricing is applied. GET integer/float
product The name or title of the product as it appears to customers. GET string
options Product variations or customizations selected by the customer (e.g., size, color, etc.). GET array
subtotal The total price for this product (price × amount). GET integer/float

Example Product Entry

{
  "product_id": "123",
  "amount": "2",
  "price": 49.99,
  "product": "Premium T-Shirt",
  "options": [
    {
      "option_id": "12",
      "option_name": "Size",
      "value": "Large"
    },
    {
      "option_id": "14",
      "option_name": "Color",
      "value": "Blue"
    }
  ],
  "subtotal": 99.98
}

Working with Cart Products

Retrieving Products in a Cart

To retrieve products in a cart, use the GET request to fetch cart details. The products array will be included in the response.

GET /api/carts/{cart_id}

Returns the detailed information about a specific cart, including all products.

Adding Products to a Cart

To add a product to a cart, use the POST request with product details.

POST /api/carts/{cart_id}/products

Adds a new product to the specified cart.

{
  "product_id": "456",
  "amount": "1",
  "options": [
    {
      "option_id": "23",
      "value": "Medium"
    }
  ]
}
Tip: When working with cart products, always verify that the product_id exists in your catalog before attempting to add it to a cart. Invalid product IDs will result in an error response.