mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-rest-api-docs.git
synced 2026-04-24 04:42:50 +08:00
2.1 KiB
2.1 KiB
Product custom fields
The product custom fields API allows you to view the custom field names that have been recorded.
Custom fields available parameters
| Parameter | Type | Description |
|---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit. Default is view. |
page |
integer | Current page of the collection. Default is 1. |
per_page |
integer | Maximum number of items to be returned in result set. Default is 10. |
search |
string | Limit results to those matching a string. |
order |
string | Order sort attribute ascending or descending. Options: asc and desc. Default is desc. |
Retrieve product custom field names
This API lets you retrieve filtered custom field names.
GET
/wp-json/wc/v3/products/custom-fields/names
curl https://example.com/wp-json/wc/v3/products/custom-fields/names \
-u consumer_key:consumer_secret
WooCommerce.get("products/custom-fields/names")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/custom-fields/names')); ?>
print(wcapi.get("products/custom-fields/names").json())
woocommerce.get("products/custom-fields/names").parsed_response
JSON response example:
{
[
"Custom field 1",
"Custom field 2",
"Custom field 3",
"Custom field 4"
]
}