Closed drmDev closed 8 years ago
Have you checked whether the WC API does this by itself? From what I remember, the simple products and the variations have slightly different API data structures and expose different fields in different ways. It may already support it, but it most likely doesn't.
Yes, the WC API does not support updating these kinds of custom fields. It only supports updating fields it is pre-defined to handle so it can validate them properly. Additional customizations or plugins would be needed to update these fields, which I was hoping this plugin would be able to acheive as well.
edit: Refer to the WC API issue https://github.com/woothemes/woocommerce/issues/7593 where it is stated "We will not support save any data that is not predefined in our API.We can't just save everything that comes through the API without proper validation and sanitization." (and where you also commented about your plugin being able to help with some of these issues). From my testing, what the collaborator claudios stated is exactly what happens.
I expect the action woocommerce_api_save_product_variation
will be needed to implement the updating of the data:
https://github.com/woothemes/woocommerce/blob/master/includes/api/class-wc-api-products.php#L1995
The action will be very similar to - if not identical to - updateCustomMeta()
:
https://github.com/judgej/wc-api-custom-meta/blob/master/wc-api-custom-meta.php#L120
A variation is just a WP post, so it will take and support metadata like any other post. How the WC templates handle metadata that they are not expecting on these variations, I don't know (we will just have to see).
If your developer has a pull request, or even a hacked version of this plugin that I can incorporate, that would be a great help.
this should be fixed by d5dbc4d195c3815f2e02418fbcc71d8d7893274f. you can probably close this bug.
Good point - thanks.
From my understanding of this plugin, we can only update custom fields directly underneath a Simple Product. It does not support updating custom fields within Variable Products - Variations.
Our custom fields often are a result of other WooCommerce plugins such as WooCommerce Dropshippers and WooCommerce Warranty and Returns. We also have created our own Variation Custom Fields through customizations from http://www.remicorson.com/woocommerce-custom-fields-for-variations/ . Being able to update all these fields by plugin would be very helpful.