Get product attributes
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/products/attributesimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/products/attributes"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/products/attributes', 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",
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"
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")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/products/attributes")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": 1,
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"Small",
"Medium",
"Large",
"X-Large",
"2X-Large"
]
},
{
"id": 2,
"name": "Color",
"position": 1,
"visible": true,
"variation": true,
"options": [
"Red",
"Blue",
"Green",
"Black",
"White",
"Navy Blue",
"Gray"
]
},
{
"id": 3,
"name": "Material",
"position": 2,
"visible": true,
"variation": false,
"options": [
"Cotton",
"Polyester",
"Wool",
"Silk"
]
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}Gets a list of product attributes.
GET
/
products
/
attributes
Error
A valid request URL is required to generate request examples[
{
"id": 1,
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"Small",
"Medium",
"Large",
"X-Large",
"2X-Large"
]
},
{
"id": 2,
"name": "Color",
"position": 1,
"visible": true,
"variation": true,
"options": [
"Red",
"Blue",
"Green",
"Black",
"White",
"Navy Blue",
"Gray"
]
},
{
"id": 3,
"name": "Material",
"position": 2,
"visible": true,
"variation": false,
"options": [
"Cotton",
"Polyester",
"Wool",
"Silk"
]
}
]{
"code": "cocart_invalid_parameter",
"message": "Invalid parameter provided.",
"data": {
"status": 400
}
}Response
Product attributes retrieved successfully.
Attribute ID.
Attribute name.
Attribute position.
Define if the attribute is visible on the "Additional information" tab in the product's page.
Define if the attribute can be used as variation.
List of available term names of the attribute.
Was this page helpful?
⌘I