Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add product custom fields documentation #245

Merged
merged 5 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions source/includes/wp-api-v3/_product-custom-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Product custom fields #

The product custom fields API allows you to view the custom field names that have been recorded.

## Product custom fields properties ##

| Attribute | Type | Description |
| --------- | ------ | ----------------------------------------------------------------------------------------------------------- |
| `key` | string | The custom field key. |
| `value` | string | The value set for the key. |

## Retrieve product custom field names ##

This API lets you retrieve filtered custom field names.

<div class="api-endpoint">
<div class="endpoint-data">
<i class="label label-get">GET</i>
<h6>/wp-json//wc/v3/products/custom-fields/names</h6>
</div>
</div>

```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
<?php print_r($woocommerce->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"
]
}
```
1 change: 1 addition & 0 deletions source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down