Get cart sessions
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/sessions \
--header 'Authorization: Basic <encoded-value>'import requests
url = "{protocol}://{host}/wp-json/cocart/v2/sessions"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('{protocol}://{host}/wp-json/cocart/v2/sessions', 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/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$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/sessions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
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/v2/sessions")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/sessions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body[
{
"session_key": "cb7a23af96a3f23af3c28a8b4b8c6d5e",
"cart": {
"d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2": {
"key": "d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2",
"product_id": 145,
"variation_id": 0,
"quantity": 2,
"line_total": 36,
"line_tax": 3.6
}
},
"customer": {
"billing_email": "john.doe@example.com",
"billing_first_name": "John",
"billing_last_name": "Doe"
},
"session_expiry": "2024-10-15T18:30:00"
},
{
"session_key": "f8d9e1a2b3c4d5e6f7a8b9c0d1e2f3a4",
"cart": {
"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6": {
"key": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"product_id": 278,
"variation_id": 289,
"quantity": 1,
"line_total": 80,
"line_tax": 8
}
},
"customer": {
"billing_email": "jane.smith@example.com",
"billing_first_name": "Jane",
"billing_last_name": "Smith"
},
"session_expiry": "2024-10-16T12:15:00"
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}{
"code": "cocart_unauthorized",
"message": "Authentication required to access sessions.",
"data": {
"status": 401
}
}{
"code": "cocart_forbidden",
"message": "You do not have permission to access sessions.",
"data": {
"status": 403
}
}Gets a list of cart sessions for administrative purposes.
GET
/
sessions
Error
A valid request URL is required to generate request examples[
{
"session_key": "cb7a23af96a3f23af3c28a8b4b8c6d5e",
"cart": {
"d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2": {
"key": "d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2",
"product_id": 145,
"variation_id": 0,
"quantity": 2,
"line_total": 36,
"line_tax": 3.6
}
},
"customer": {
"billing_email": "john.doe@example.com",
"billing_first_name": "John",
"billing_last_name": "Doe"
},
"session_expiry": "2024-10-15T18:30:00"
},
{
"session_key": "f8d9e1a2b3c4d5e6f7a8b9c0d1e2f3a4",
"cart": {
"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6": {
"key": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"product_id": 278,
"variation_id": 289,
"quantity": 1,
"line_total": 80,
"line_tax": 8
}
},
"customer": {
"billing_email": "jane.smith@example.com",
"billing_first_name": "Jane",
"billing_last_name": "Smith"
},
"session_expiry": "2024-10-16T12:15:00"
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}{
"code": "cocart_unauthorized",
"message": "Authentication required to access sessions.",
"data": {
"status": 401
}
}{
"code": "cocart_forbidden",
"message": "You do not have permission to access sessions.",
"data": {
"status": 403
}
}Authorizations
basicAuthbearerAuth
Basic authentication with username and password.
Query Parameters
Current page of the collection.
Maximum number of items to return per page.
Was this page helpful?
⌘I