wc-api-custom-meta
wc-api-custom-meta copied to clipboard
set data into a custom field
Hey guys, I dont know how i have to write some rest request to set a value in to my custom field. I have installed your Plugin and i have created a custom field like http://www.remicorson.com/mastering-woocommerce-products-custom-fields/ Now the question is how i have to write the rest request to set data in this custom field.
I tried it like "custom_meta": [ { "my_custom_field_id": "my_custom_value", } ]
Hi,
What you have given should work, if I am reading it correctly. However, you may have an extra level in the structure there. Try this instead:
"custom_meta": {
"my_custom_field_id": "my_custom_value",
}
You have an array of objects, while it should be one object with one or more properties that match the custom fields. I'm guessing you aren't using PHP to write to the API (just a guess), but in PHP this would be an associative array.
If doing it this way is counter-intuitive to non-PHP users of the API, then I'm happy to change it to take a more standard cross-platform approach.
Use the new v2 REST API (WC 3.x) instead of this plugin. It now does everything this plugin does out of the box. The README gives some examples of how you would manage the metadata fields.