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_item_key",
"message": "Invalid item key format.",
"data": {
"status": 400
}
}{
"code": "cocart_cannot_restore_item",
"message": "Unable to restore this item to the cart.",
"data": {
"status": 403
}
}{
"code": "cocart_item_not_found",
"message": "Cart item not found in removed items.",
"data": {
"status": 404
}
}PUT
/
cart
/
item
/
{item_key}
Restore cart item
curl --request PUT \
--url {protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}import requests
url = "{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}"
response = requests.put(url)
print(response.text)const options = {method: 'PUT'};
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 => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}"
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("{protocol}://{host}/wp-json/cocart/v2/cart/item/{item_key}")
.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::Put.new(url)
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_item_key",
"message": "Invalid item key format.",
"data": {
"status": 400
}
}{
"code": "cocart_cannot_restore_item",
"message": "Unable to restore this item to the cart.",
"data": {
"status": 403
}
}{
"code": "cocart_item_not_found",
"message": "Cart item not found in removed items.",
"data": {
"status": 404
}
}Path Parameters
Unique identifier for the cart item.
Pattern:
^[\w-]{32}$Query Parameters
Returns the item details once restored.
Response
Cart item restored successfully.
- Option 1
- Option 2
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