Adding a product to a cart will sometimes require more than just the Product ID. Depending on the specifications of the product you may need to set a specific qty or options, or even super_group or super_attribute, depending on which type of product you are adding.
For more examples of how to add different products, use the example drop-down to change the Example Request.
Query Parameters
| key | type | description |
|---|---|---|
return_data | string | Optional. What to return instead of true. Supported value: items, which returns the cart item IDs of the added products (see Response). A missing or unsupported value returns true. |
return_data must be sent in the query string, e.g. POST /checkout2/cart_product?return_data=items. It is not read from the request body.
Product Data
| key | type | description |
|---|---|---|
product_id | string | int |
sku | string | The product to add, by SKU. |
qty | string | int |
custom_price | string | float |
use_discount | flag (1 | 0) |
unique_in_quote | flag (1 | 0) |
super_attribute | SuperAttributes | Used to configure a Configurable product. |
super_group | SuperGroup | Used to configure a Grouped product. |
bundle_option | BundleOptions | Used to configure a Bundle's simple products. |
bundle_option_qty | BundleOptionQtys | Used to configure a Bundle's simple product qty. |
comment | string | Used to set a comment on the item. |
options | string | int |
SuperAttributes
| key | type | description |
|---|---|---|
| Custom Option Id | string | int |
SuperGroup
| key | type | description |
|---|---|---|
| Grouped Product ID | string | int |
BundleOptions
| key | type | description |
|---|---|---|
| Bundle Option ID | string | int |
BundleOptionQtys
| key | type | description |
|---|---|---|
| Bundle Option ID | string | int |
DateOptionValue
| key | type | description |
|---|---|---|
month | string | int |
day | string | int |
year | string | int |
hour | string | int |
minute | string | int |
day_part | string | am or pm if your store uses AM/PM. (Required for DateTime / Time) |
Response
Without return_data, a successful call returns true.
With ?return_data=items, it returns the cart and one entry per product in the request, in the same order:
{
"cartId": 123,
"items": [
{ "item_id": 9001, "product_id": 12, "sku": "A", "qty": 2 },
{ "item_id": 9003, "product_id": 80, "sku": "C-RED-L", "qty": 1, "variation_product_id": 84 },
{ "product_id": 70, "sku": "G", "items": [
{ "item_id": 9010, "product_id": 71, "sku": "G-1", "qty": 2 },
{ "item_id": 9011, "product_id": 72, "sku": "G-2", "qty": 1 }
] }
]
}
| key | type | description |
|---|---|---|
item_id | int | null |
product_id | int | The product added. For a configurable product, the configurable (parent) product. |
sku | string | The item's SKU. For a configurable product, the selected variant's SKU. |
qty | float | The cart line's total qty after the add. If the product merged into a line already in the cart, this includes the qty that was already there. |
variation_product_id | int | null |
items | array | Grouped products only: one entry per child product added, with the fields above. A grouped entry has no item_id of its own. |
Notes:
-
Adding a product that is already in the cart with the same options merges into that line. Its entry returns the existing
item_idand the combinedqty. Sendunique_in_quote: 1to get a separate line. -
If the same product appears twice in one request and merges, both entries return the same
item_id. -
If any product fails to add, the call returns an error and nothing is added.
-
An
item_idofnullmeans the product was added but its ID couldn't be returned. Don't retry the add; get the ID withGET /checkout2/cart_product?id=.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
