wc-api-custom-meta
wc-api-custom-meta copied to clipboard
Won't update variation meta
Hi, I'm having a problem with this plugin where updating a simple product works fine with the api call:
- endpoint: products/<simple_product_id>
- data: {'custom_meta': {'field':'value'} }
However this doesn't work with product variations, for example if i have a variable product, which has a number of variations whose properties change regularly and I need to update those variations without deleting and re-creating them every time I update them, I want to be able to do this:
- endpoint: products/<variation_id> (not the id of the parent product but the ID of the variation
- data: {'custom_meta': {'field':'value'} }
However this just doesn't work on Variations, it just ignores it.
I also can't obtain the meta of a product variation through this plugin, only the meta of the variable product which is it's parent.
I've fixed these issues in my fork, let me know if you'd like me to submit a pull request and i can get on that.
https://github.com/derwentx/wc-api-custom-meta/commit/1103dcc0f6dd2ee4cb96c706e0589c984b17ed22
Changes I've made:
- When accessing a product variation directly via
product/<variation_id>
it gives the variation's meta instead of the parent's meta. - When modifying a product variation directly via
product/<variation_id>
the API can directly modify the the variation's meta which was not possible before.
Let me know what you think, thanks
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.