How to handle this endpoint
/wp-json/wc/v3/products/?_fields=name,meta_data
[
{
"name": "Test",
"meta_data": [
{
"id": 478626,
"key": "_wp_page_template",
"value": "default"
},
to achieve this?
[
{
"name": "Test",
"meta_data": [
{
"value": "default"
},
I took a look at the documentation, but I didn't find anything relevant.
Since meta_data
is an array
, this syntax DOESN'T work:
/wp-json/wc/v3/products/?_fields=name,meta_data.value
How to handle this endpoint
/wp-json/wc/v3/products/?_fields=name,meta_data
[
{
"name": "Test",
"meta_data": [
{
"id": 478626,
"key": "_wp_page_template",
"value": "default"
},
to achieve this?
[
{
"name": "Test",
"meta_data": [
{
"value": "default"
},
I took a look at the documentation, but I didn't find anything relevant.
Since meta_data
is an array
, this syntax DOESN'T work:
/wp-json/wc/v3/products/?_fields=name,meta_data.value
Does this only work with the meta_data object for accessing nested items in an array? I tried it with woo commerce subscription line_items and did not seem to work.
_fields
parameter supports nested properties", so try_fields=name,meta_data.value
..? But can't you just retrieve only thevalue
property from within your application? – Sally CJ Commented May 27, 2022 at 4:25[
. And I don't think an "any (numeric) array key" is supported (i.e. the key must be explicitly specified, e.g.meta_data.0.value
andmeta_data.1.value
), so maybe you should just use the standard way - keep the original structure and in your app, get just the property you need from each item in themeta_data
array. – Sally CJ Commented May 27, 2022 at 16:43meta_data.0.value
DOESN'T work as well. – Marcel Commented May 27, 2022 at 21:15