Update a Cart Item
PUThttps://useast.api.elasticpath.com/v2/carts/:cartID/items/:cartitemID
You can easily update a cart item. A successful update returns the cart items.
Request
Path Parameters
cartID stringrequired
A unique identifier of the cart that you created.
cartitemID stringrequired
A unique identifier of the cart item.
- application/json
Body
data object
Responses
- 200
- 400
- 404
Response Headers
- application/json
- Schema
- Example (auto)
Schema
data object[]
meta object
{
"data": [
{
"type": "cart_item",
"quantity": 0,
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sku": "string",
"custom_inputs": {},
"bundle_configuration": {
"selected_options": {},
"component_products": [
null
]
},
"shipping_group_id": "string",
"location": "string",
"product_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"subscription_offering_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"description": "string",
"catalog_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"catalog_source": "string",
"image": {
"mime_type": "string",
"file_name": "string",
"href": "string"
},
"manage_stock": true,
"unit_price": {
"amount": 0,
"currency": "string",
"includes_tax": true
},
"value": {
"amount": 0,
"currency": "string",
"includes_tax": true
},
"links": {
"product": "string"
},
"meta": {
"display_price": {
"with_tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"without_tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"discount": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"without_discount": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
}
},
"timestamps": {
"created_at": "2023-11-07T23:04:18.845Z",
"updated_at": "2023-11-07T23:04:18.845Z"
}
}
},
{
"data": {
"type": "custom_item",
"quantity": 0,
"price": {
"amount": 0,
"includes_tax": true
},
"description": "string",
"sku": "string",
"name": "string",
"custom_inputs": {},
"shipping_group_id": "string"
}
},
{
"data": {
"type": "subscription_item",
"quantity": 0,
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"product_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"subscription_offering_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"description": "string",
"catalog_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"catalog_source": "string",
"image": {
"mime_type": "string",
"file_name": "string",
"href": "string"
},
"manage_stock": true,
"unit_price": {
"amount": 0,
"currency": "string",
"includes_tax": true
},
"value": {
"amount": 0,
"currency": "string",
"includes_tax": true
},
"links": {
"product": "string"
},
"meta": {
"display_price": {
"with_tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"without_tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"tax": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"discount": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"without_discount": {
"unit": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"value": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
}
},
"timestamps": {
"created_at": "2023-11-07T23:04:18.845Z",
"updated_at": "2023-11-07T23:04:18.845Z"
}
}
}
},
{
"data": {
"type": "promotion_item",
"code": "string"
}
}
],
"meta": {
"display_price": {
"with_tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"without_tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"discount": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"without_discount": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"discounts": {}
},
"timestamps": {
"created_at": "2023-11-07T23:04:18.845Z",
"updated_at": "2023-11-07T23:04:18.845Z",
"expires_at": "2023-11-12T23:04:18.845Z"
}
}
}
Bad Request
- application/json
- Schema
- Example (auto)
- default
Schema
errors object[]required
{
"errors": [
{
"title": "string",
"detail": "string",
"meta": {
"id": "string",
"ids": [
"string"
],
"item_ids": [
"string"
],
"shipping_group_id": "string",
"shipping_group_ids": [
"string"
],
"cart_id": "string",
"code": "string",
"order_id": "string"
}
}
]
}
Cart Currency Mismatch
{
"errors": [
{
"detail": "The existing shipping group uses USD, cannot add this shipping group to a cart item with currency GBP",
"meta": {
"item_ids": [
"51197fc0-e217-4f69-a769-b3887f58cfff"
],
"shipping_group_id": "fcb87ec9-a7fb-48c2-bcd9-2151b64e1abc"
},
"status": 404,
"title": "Cart Currency Mismatch"
}
]
}
Not Found
- application/json
- Schema
- Example (auto)
- default
Schema
errors object[]required
{
"errors": [
{
"title": "string",
"detail": "string",
"meta": {
"id": "string",
"ids": [
"string"
],
"item_ids": [
"string"
],
"shipping_group_id": "string",
"shipping_group_ids": [
"string"
],
"cart_id": "string",
"code": "string",
"order_id": "string"
}
}
]
}
Not Found
{
"errors": [
{
"detail": "Shipping groups not found for this cart. Please verify the shipping groups exists for this cart and are not already associated with orders.",
"meta": {
"cart_id": "a-cart-id",
"shipping_group_ids": [
"fcb87ec9-a7fb-48c2-bcd9-2151b64e1abc"
]
},
"status": 404,
"title": "Shipping groups not found"
}
]
}
Authorization: http
name: bearerAuthtype: httpscheme: bearer
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://useast.api.elasticpath.com/v2/carts/:cartID/items/:cartitemID");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"type\": \"cart_item\",\n \"id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"quantity\": 0,\n \"custom_inputs\": {},\n \"shipping_group_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear