Error
A valid request URL is required to generate request examples{
"cart_key": "abc123def456",
"cart_hash": "d41d8cd98f00b204e9800998ecf8427e",
"currency": {
"code": "USD",
"symbol": "$",
"base_currency": "USD",
"exchange_rate": 1
},
"customer_id": 123,
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"cart_contents": {
"c4ca4238a0b923820dcc509a6f75849b": {
"key": "c4ca4238a0b923820dcc509a6f75849b",
"product_id": 456,
"variation_id": 0,
"quantity": 2,
"product_name": "Premium T-Shirt",
"product_title": "Premium T-Shirt",
"product_price": "$19.99",
"line_total": "39.98",
"line_subtotal": "39.98"
}
},
"cart_totals": {
"subtotal": "39.98",
"subtotal_tax": "0.00",
"shipping_total": "5.00",
"shipping_tax": "0.00",
"discount_total": "0.00",
"discount_tax": "0.00",
"cart_contents_total": "39.98",
"cart_contents_tax": "0.00",
"fee_total": "0.00",
"fee_tax": "0.00",
"total": "44.98",
"total_tax": "0.00"
},
"shipping_methods": {
"flat_rate:1": {
"id": "flat_rate:1",
"label": "Flat Rate",
"cost": "5.00",
"method_id": "flat_rate",
"instance_id": "1"
}
},
"needs_payment": true,
"needs_shipping": true,
"payment_method": "stripe"
}
Retrieve current checkout information including cart contents, totals, addresses, and available shipping/payment methods
GET
/
checkout
Get checkout data
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/preview/checkoutimport requests
url = "{protocol}://{host}/wp-json/cocart/preview/checkout"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/preview/checkout', 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/preview/checkout",
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/preview/checkout"
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/preview/checkout")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/preview/checkout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"cart_key": "abc123def456",
"cart_hash": "d41d8cd98f00b204e9800998ecf8427e",
"currency": {
"code": "USD",
"symbol": "$",
"base_currency": "USD",
"exchange_rate": 1
},
"customer_id": 123,
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"cart_contents": {
"c4ca4238a0b923820dcc509a6f75849b": {
"key": "c4ca4238a0b923820dcc509a6f75849b",
"product_id": 456,
"variation_id": 0,
"quantity": 2,
"product_name": "Premium T-Shirt",
"product_title": "Premium T-Shirt",
"product_price": "$19.99",
"line_total": "39.98",
"line_subtotal": "39.98"
}
},
"cart_totals": {
"subtotal": "39.98",
"subtotal_tax": "0.00",
"shipping_total": "5.00",
"shipping_tax": "0.00",
"discount_total": "0.00",
"discount_tax": "0.00",
"cart_contents_total": "39.98",
"cart_contents_tax": "0.00",
"fee_total": "0.00",
"fee_tax": "0.00",
"total": "44.98",
"total_tax": "0.00"
},
"shipping_methods": {
"flat_rate:1": {
"id": "flat_rate:1",
"label": "Flat Rate",
"cost": "5.00",
"method_id": "flat_rate",
"instance_id": "1"
}
},
"needs_payment": true,
"needs_shipping": true,
"payment_method": "stripe"
}
This endpoint is currently shown as a preview of what’s currently in development and is subject to change.
Response
Checkout data retrieved successfully
Unique identifier for the cart session
MD5 hash of cart contents
Currency information including code, symbol, and exchange rate
Show child attributes
Show child attributes
Customer ID, if logged in
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Cart contents with product details
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Available shipping methods
Show child attributes
Show child attributes
Whether the cart needs payment
Whether the cart needs shipping
Selected payment method
Was this page helpful?
⌘I