Get cart contents
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v1/get-cartimport requests
url = "{protocol}://{host}/wp-json/cocart/v1/get-cart"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v1/get-cart', 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/v1/get-cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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/v1/get-cart"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("{protocol}://{host}/wp-json/cocart/v1/get-cart")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v1/get-cart")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"1c383cd30b7c298ab50293adfecb7b18": {
"key": "1c383cd30b7c298ab50293adfecb7b18",
"product_id": 35,
"variation_id": 0,
"variation": [],
"quantity": 6,
"data_hash": "b5c1d5ca8bae6d4896cf1807cdf763f0",
"line_tax_data": {
"subtotal": [],
"total": []
},
"line_subtotal": 108,
"line_subtotal_tax": 0,
"line_total": 108,
"line_tax": 0,
"data": {},
"product_name": "T-Shirt with Logo",
"product_title": "T-Shirt with Logo",
"product_price": "£18.00"
},
"70efdf2ec9b086079795c442636b55fb": {
"key": "70efdf2ec9b086079795c442636b55fb",
"product_id": 17,
"variation_id": 0,
"variation": [],
"quantity": 5,
"data_hash": "b5c1d5ca8bae6d4896cf1807cdf763f0",
"line_tax_data": {
"subtotal": [],
"total": []
},
"line_subtotal": 225,
"line_subtotal_tax": 0,
"line_total": 225,
"line_tax": 0,
"data": {},
"product_name": "Hoodie with Logo",
"product_title": "Hoodie with Logo",
"product_price": "£45.00"
}
}Gets the cart items added by the customer.
GET
/
get-cart
Get cart contents
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v1/get-cartimport requests
url = "{protocol}://{host}/wp-json/cocart/v1/get-cart"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v1/get-cart', 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/v1/get-cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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/v1/get-cart"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("{protocol}://{host}/wp-json/cocart/v1/get-cart")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v1/get-cart")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"1c383cd30b7c298ab50293adfecb7b18": {
"key": "1c383cd30b7c298ab50293adfecb7b18",
"product_id": 35,
"variation_id": 0,
"variation": [],
"quantity": 6,
"data_hash": "b5c1d5ca8bae6d4896cf1807cdf763f0",
"line_tax_data": {
"subtotal": [],
"total": []
},
"line_subtotal": 108,
"line_subtotal_tax": 0,
"line_total": 108,
"line_tax": 0,
"data": {},
"product_name": "T-Shirt with Logo",
"product_title": "T-Shirt with Logo",
"product_price": "£18.00"
},
"70efdf2ec9b086079795c442636b55fb": {
"key": "70efdf2ec9b086079795c442636b55fb",
"product_id": 17,
"variation_id": 0,
"variation": [],
"quantity": 5,
"data_hash": "b5c1d5ca8bae6d4896cf1807cdf763f0",
"line_tax_data": {
"subtotal": [],
"total": []
},
"line_subtotal": 225,
"line_subtotal_tax": 0,
"line_total": 225,
"line_tax": 0,
"data": {},
"product_name": "Hoodie with Logo",
"product_title": "Hoodie with Logo",
"product_price": "£45.00"
}
}Query Parameters
Unique identifier for the cart/customer.
Returns the URL of the product image thumbnail.
Response
200 - application/json
List of cart items.
A map of cart item keys to cart item objects. Each property key is a unique cart item key.
Show child attributes
Show child attributes
Was this page helpful?
⌘I