diff --git a/source/includes/wp-api-v3/_product-custom-fields.md b/source/includes/wp-api-v3/_product-custom-fields.md new file mode 100644 index 0000000..927e7eb --- /dev/null +++ b/source/includes/wp-api-v3/_product-custom-fields.md @@ -0,0 +1,64 @@ +# 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
+
+
+ +```shell +curl https://example.com/wp-json/wc/v3/products/custom-fields/names \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get("products/custom-fields/names") + .then((response) => { + console.log(response.data); + }) + .catch((error) => { + console.log(error.response.data); + }); +``` + +```php +get('products/custom-fields/names')); ?> +``` + +```python +print(wcapi.get("products/custom-fields/names").json()) +``` + +```ruby +woocommerce.get("products/custom-fields/names").parsed_response +``` + +> JSON response example: + +```json +{ + [ + "Custom field 1", + "Custom field 2", + "Custom field 3", + "Custom field 4" + ] +} +``` diff --git a/source/index.html.md b/source/index.html.md index 7f4914a..c98e0ea 100644 --- a/source/index.html.md +++ b/source/index.html.md @@ -31,6 +31,7 @@ includes: - wp-api-v3/product-attributes - wp-api-v3/product-attribute-terms - wp-api-v3/product-categories + - wp-api-v3/product-custom-fields - wp-api-v3/product-shipping-classes - wp-api-v3/product-tags - wp-api-v3/product-reviews