Get single product attribute
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}import requests
url = "{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}', 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}",
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}"
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}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"position": 123,
"visible": true,
"variation": true,
"options": [
"<string>"
]
}{
"code": "cocart_invalid_attribute_id",
"message": "Invalid attribute ID provided.",
"data": {
"status": 400
}
}{
"code": "cocart_attribute_not_found",
"message": "Product attribute not found.",
"data": {
"status": 404
}
}Get a Product Attribute by ID
Gets a single product attribute by ID.
GET
/
products
/
attributes
/
{id}
Get single product attribute
curl --request GET \
--url {protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}import requests
url = "{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}', 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}",
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}"
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}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/products/attributes/{id}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"position": 123,
"visible": true,
"variation": true,
"options": [
"<string>"
]
}{
"code": "cocart_invalid_attribute_id",
"message": "Invalid attribute ID provided.",
"data": {
"status": 400
}
}{
"code": "cocart_attribute_not_found",
"message": "Product attribute not found.",
"data": {
"status": 404
}
}Path Parameters
Unique identifier for the attribute.
Response
Product attribute 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.