Get cart totals
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/cart/totalsimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/cart/totals"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/cart/totals', 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/totals",
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/v2/cart/totals"
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/v2/cart/totals")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/cart/totals")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"subtotal": "116.00",
"subtotal_tax": "11.60",
"shipping_total": "10.00",
"shipping_tax": "1.00",
"shipping_taxes": [
1
],
"discount_total": "23.20",
"discount_tax": "0.00",
"cart_contents_total": "92.80",
"cart_contents_tax": "11.10",
"cart_contents_taxes": [
11.1
],
"fee_total": "5.00",
"fee_tax": "0.50",
"fee_taxes": [
0.5
],
"total": "119.40",
"total_tax": "13.60"
}{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}Get Cart Totals
Get the carts totals.
GET
/
cart
/
totals
Get cart totals
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/cart/totalsimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/cart/totals"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/cart/totals', 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/totals",
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/v2/cart/totals"
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/v2/cart/totals")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/cart/totals")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"subtotal": "116.00",
"subtotal_tax": "11.60",
"shipping_total": "10.00",
"shipping_tax": "1.00",
"shipping_taxes": [
1
],
"discount_total": "23.20",
"discount_tax": "0.00",
"cart_contents_total": "92.80",
"cart_contents_tax": "11.10",
"cart_contents_taxes": [
11.1
],
"fee_total": "5.00",
"fee_tax": "0.50",
"fee_taxes": [
0.5
],
"total": "119.40",
"total_tax": "13.60"
}{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}This endpoint will be deprecated in the future. Recommend getting the totals from the main cart endpoint.
Query Parameters
Returns the totals pre-formatted.
Response
Cart totals retrieved successfully.
Cart subtotal.
Cart subtotal tax.
Shipping total.
Shipping tax.
Discount total.
Discount tax.
Cart contents total.
Cart contents tax.
Fee total.
Fee tax.
Cart total.
Total tax.