Get product attribute terms
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/termsimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms', 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/products/attributes/{id}/terms",
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/products/attributes/{id}/terms"
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/products/attributes/{id}/terms")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": 23,
"name": "Small",
"slug": "small",
"description": "Small size",
"menu_order": 0,
"count": 45
},
{
"id": 24,
"name": "Medium",
"slug": "medium",
"description": "Medium size",
"menu_order": 1,
"count": 78
},
{
"id": 25,
"name": "Large",
"slug": "large",
"description": "Large size",
"menu_order": 2,
"count": 67
},
{
"id": 26,
"name": "X-Large",
"slug": "x-large",
"description": "Extra large size",
"menu_order": 3,
"count": 42
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}{
"code": "cocart_attribute_not_found",
"message": "Product attribute not found.",
"data": {
"status": 404
}
}Get a Product Attributes Terms
Gets terms for a specific product attribute.
GET
/
products
/
attributes
/
{id}
/
terms
Get product attribute terms
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/termsimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms', 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/products/attributes/{id}/terms",
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/products/attributes/{id}/terms"
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/products/attributes/{id}/terms")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}/terms")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": 23,
"name": "Small",
"slug": "small",
"description": "Small size",
"menu_order": 0,
"count": 45
},
{
"id": 24,
"name": "Medium",
"slug": "medium",
"description": "Medium size",
"menu_order": 1,
"count": 78
},
{
"id": 25,
"name": "Large",
"slug": "large",
"description": "Large size",
"menu_order": 2,
"count": 67
},
{
"id": 26,
"name": "X-Large",
"slug": "x-large",
"description": "Extra large size",
"menu_order": 3,
"count": 42
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}{
"code": "cocart_attribute_not_found",
"message": "Product attribute not found.",
"data": {
"status": 404
}
}Query Parameters
Response
Product attribute terms retrieved successfully.