Error
A valid request URL is required to generate request examples{
"cart_hash": "<string>",
"cart_key": "<string>",
"currency": {
"currency_code": "<string>",
"currency_symbol": "<string>",
"currency_symbol_pos": "<string>",
"currency_minor_unit": 123,
"currency_decimal_separator": "<string>",
"currency_thousand_separator": "<string>",
"currency_prefix": "<string>",
"currency_suffix": "<string>"
},
"customer": {
"billing_address": {
"billing_first_name": "<string>",
"billing_last_name": "<string>",
"billing_company": "<string>",
"billing_country": "<string>",
"billing_address_1": "<string>",
"billing_address_2": "<string>",
"billing_postcode": "<string>",
"billing_city": "<string>",
"billing_state": "<string>",
"billing_phone": "<string>",
"billing_email": "<string>"
},
"shipping_address": {
"shipping_first_name": "<string>",
"shipping_last_name": "<string>",
"shipping_company": "<string>",
"shipping_country": "<string>",
"shipping_address_1": "<string>",
"shipping_address_2": "<string>",
"shipping_postcode": "<string>",
"shipping_city": "<string>",
"shipping_state": "<string>"
}
},
"items": {},
"item_count": 123,
"items_weight": 123,
"coupons": [
{
"coupon": "<string>",
"label": "<string>",
"saving": "<string>",
"saving_html": "<string>"
}
],
"needs_payment": true,
"needs_shipping": true,
"shipping": {
"total_packages": 123,
"show_package_details": true,
"has_calculated_shipping": true,
"packages": {}
},
"fees": [
{
"name": "<string>",
"amount": 123,
"taxable": true,
"tax_class": "<string>",
"total": 123,
"tax": 123
}
],
"taxes": [
{
"rate_id": 123,
"label": "<string>",
"compound": true,
"tax_total": "<string>",
"shipping_tax_total": "<string>"
}
],
"totals": {
"subtotal": "<string>",
"subtotal_tax": "<string>",
"shipping_total": "<string>",
"shipping_tax": "<string>",
"shipping_taxes": [
123
],
"discount_total": "<string>",
"discount_tax": "<string>",
"cart_contents_total": "<string>",
"cart_contents_tax": "<string>",
"cart_contents_taxes": [
123
],
"fee_total": "<string>",
"fee_tax": "<string>",
"fee_taxes": [
123
],
"total": "<string>",
"total_tax": "<string>"
},
"removed_items": [
{
"key": "<string>",
"product_id": 123,
"quantity": 123,
"name": "<string>"
}
],
"cross_sells": [
{
"id": 123,
"product_name": "<string>",
"product_title": "<string>",
"price": "<string>",
"regular_price": "<string>",
"sale_price": "<string>",
"product_image": "<string>"
}
],
"notices": {},
"extensions": {}
}{
"code": "cocart_invalid_quantity",
"message": "Invalid quantity provided.",
"data": {
"status": 400
}
}{
"code": "cocart_item_not_found",
"message": "Cart item not found.",
"data": {
"status": 404
}
}POST
/
cart
/
item
/
{item_key}
Update cart item
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key} \
--header 'Content-Type: application/json' \
--data '
{
"quantity": "<string>",
"return_status": false
}
'import requests
url = "{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}"
payload = {
"quantity": "<string>",
"return_status": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({quantity: '<string>', return_status: false})
};
fetch('{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'quantity' => '<string>',
'return_status' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}"
payload := strings.NewReader("{\n \"quantity\": \"<string>\",\n \"return_status\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}")
.header("Content-Type", "application/json")
.body("{\n \"quantity\": \"<string>\",\n \"return_status\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"quantity\": \"<string>\",\n \"return_status\": false\n}"
response = http.request(request)
puts response.read_body{
"cart_hash": "<string>",
"cart_key": "<string>",
"currency": {
"currency_code": "<string>",
"currency_symbol": "<string>",
"currency_symbol_pos": "<string>",
"currency_minor_unit": 123,
"currency_decimal_separator": "<string>",
"currency_thousand_separator": "<string>",
"currency_prefix": "<string>",
"currency_suffix": "<string>"
},
"customer": {
"billing_address": {
"billing_first_name": "<string>",
"billing_last_name": "<string>",
"billing_company": "<string>",
"billing_country": "<string>",
"billing_address_1": "<string>",
"billing_address_2": "<string>",
"billing_postcode": "<string>",
"billing_city": "<string>",
"billing_state": "<string>",
"billing_phone": "<string>",
"billing_email": "<string>"
},
"shipping_address": {
"shipping_first_name": "<string>",
"shipping_last_name": "<string>",
"shipping_company": "<string>",
"shipping_country": "<string>",
"shipping_address_1": "<string>",
"shipping_address_2": "<string>",
"shipping_postcode": "<string>",
"shipping_city": "<string>",
"shipping_state": "<string>"
}
},
"items": {},
"item_count": 123,
"items_weight": 123,
"coupons": [
{
"coupon": "<string>",
"label": "<string>",
"saving": "<string>",
"saving_html": "<string>"
}
],
"needs_payment": true,
"needs_shipping": true,
"shipping": {
"total_packages": 123,
"show_package_details": true,
"has_calculated_shipping": true,
"packages": {}
},
"fees": [
{
"name": "<string>",
"amount": 123,
"taxable": true,
"tax_class": "<string>",
"total": 123,
"tax": 123
}
],
"taxes": [
{
"rate_id": 123,
"label": "<string>",
"compound": true,
"tax_total": "<string>",
"shipping_tax_total": "<string>"
}
],
"totals": {
"subtotal": "<string>",
"subtotal_tax": "<string>",
"shipping_total": "<string>",
"shipping_tax": "<string>",
"shipping_taxes": [
123
],
"discount_total": "<string>",
"discount_tax": "<string>",
"cart_contents_total": "<string>",
"cart_contents_tax": "<string>",
"cart_contents_taxes": [
123
],
"fee_total": "<string>",
"fee_tax": "<string>",
"fee_taxes": [
123
],
"total": "<string>",
"total_tax": "<string>"
},
"removed_items": [
{
"key": "<string>",
"product_id": 123,
"quantity": 123,
"name": "<string>"
}
],
"cross_sells": [
{
"id": 123,
"product_name": "<string>",
"product_title": "<string>",
"price": "<string>",
"regular_price": "<string>",
"sale_price": "<string>",
"product_image": "<string>"
}
],
"notices": {},
"extensions": {}
}{
"code": "cocart_invalid_quantity",
"message": "Invalid quantity provided.",
"data": {
"status": 400
}
}{
"code": "cocart_item_not_found",
"message": "Cart item not found.",
"data": {
"status": 404
}
}Path Parameters
Unique identifier for the cart item.
Pattern:
^[\w-]{32}$Body
application/json
Response
Cart item updated successfully.
- Option 1
- Status Message
Complete cart object with enhanced v2 structure.
Unique cart hash.
Unique cart key for the customer.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Cart items indexed by item key.
Show child attributes
Show child attributes
Total number of items in cart.
Total weight of all items.
Applied coupons.
Show child attributes
Show child attributes
Whether the cart needs payment.
Whether the cart needs shipping.
Show child attributes
Show child attributes
Cart fees.
Show child attributes
Show child attributes
Cart taxes.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Recently removed items that can be restored.
Show child attributes
Show child attributes
Cross-sell products.
Show child attributes
Show child attributes
Cart notices and messages.
Additional data from extensions.
Was this page helpful?
⌘I