Skip to content

Commit a9e60e6

Browse files
authored
Merge pull request #245 from woocommerce/add/46921_product_custom_fields_docs
Add product custom fields documentation
2 parents 561fb51 + 4936b6d commit a9e60e6

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Product custom fields #
2+
3+
The product custom fields API allows you to view the custom field names that have been recorded.
4+
5+
## Custom fields available parameters ##
6+
7+
| Parameter | Type | Description |
8+
| ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
9+
| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. Default is `view`. |
10+
| `page` | integer | Current page of the collection. Default is `1`. |
11+
| `per_page` | integer | Maximum number of items to be returned in result set. Default is `10`. |
12+
| `search` | string | Limit results to those matching a string. |
13+
| `order` | string | Order sort attribute ascending or descending. Options: `asc` and `desc`. Default is `desc`. |
14+
15+
## Retrieve product custom field names ##
16+
17+
This API lets you retrieve filtered custom field names.
18+
19+
<div class="api-endpoint">
20+
<div class="endpoint-data">
21+
<i class="label label-get">GET</i>
22+
<h6>/wp-json/wc/v3/products/custom-fields/names</h6>
23+
</div>
24+
</div>
25+
26+
```shell
27+
curl https://example.com/wp-json/wc/v3/products/custom-fields/names \
28+
-u consumer_key:consumer_secret
29+
```
30+
31+
```javascript
32+
WooCommerce.get("products/custom-fields/names")
33+
.then((response) => {
34+
console.log(response.data);
35+
})
36+
.catch((error) => {
37+
console.log(error.response.data);
38+
});
39+
```
40+
41+
```php
42+
<?php print_r($woocommerce->get('products/custom-fields/names')); ?>
43+
```
44+
45+
```python
46+
print(wcapi.get("products/custom-fields/names").json())
47+
```
48+
49+
```ruby
50+
woocommerce.get("products/custom-fields/names").parsed_response
51+
```
52+
53+
> JSON response example:
54+
55+
```json
56+
{
57+
[
58+
"Custom field 1",
59+
"Custom field 2",
60+
"Custom field 3",
61+
"Custom field 4"
62+
]
63+
}
64+
```

source/index.html.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ includes:
3131
- wp-api-v3/product-attributes
3232
- wp-api-v3/product-attribute-terms
3333
- wp-api-v3/product-categories
34+
- wp-api-v3/product-custom-fields
3435
- wp-api-v3/product-shipping-classes
3536
- wp-api-v3/product-tags
3637
- wp-api-v3/product-reviews

0 commit comments

Comments
 (0)