Back to Woocommerce

Product custom fields

docs/apis/rest-api/v3/product-custom-fields.mdx

10.9.0-dev2.4 KB
Original Source

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Product custom fields

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

Custom fields available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
orderstringOrder 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.

http
GET /wp-json/wc/v3/products/custom-fields/names
<Tabs> <TabItem value="curl" label="cURL">
shell
curl https://example.com/wp-json/wc/v3/products/custom-fields/names \
	-u consumer_key:consumer_secret
</TabItem> <TabItem value="js" label="JavaScript">
javascript
WooCommerce.get( 'products/custom-fields/names' )
	.then( ( response ) => {
		console.log( response.data );
	} )
	.catch( ( error ) => {
		console.log( error.response.data );
	} );
</TabItem> <TabItem value="php" label="PHP">
php
<?php print_r($woocommerce->get('products/custom-fields/names')); ?>
</TabItem> <TabItem value="python" label="Python">
python
print(wcapi.get("products/custom-fields/names").json())
</TabItem> <TabItem value="ruby" label="Ruby">
ruby
woocommerce.get("products/custom-fields/names").parsed_response
</TabItem> <TabItem value="response" label="JSON Response">
json
[
	"Custom field 1",
	"Custom field 2",
	"Custom field 3",
	"Custom field 4"
]
</TabItem> </Tabs>