I have a custom field set up in WooCommerce products (wps_item_id) and when I request product info, the field shows up. However, if I try to write to the field, there is no change.
The above code will write to any native WooCommerce field, but I cannot get it to write to wps_item_id['raw']
Woocommerce does not return any errors, it merely discards what it cannot use.
I suspect that while I can read the data using the API, I cannot write back to it as the Toolset mapping is for output only, not for input. I do hope I'm wrong. If there is a way around this, I would greatly appreciate hearing about it.
The Toolset REST API is currently read-only, it doesn't offer write capabilities.
Custom fields created with Toolset Types are "just" ordinary post meta, which is literally true for simple fields stored as strings, although a field such as an image field—which stores the image URL—when output will the a full image tag with sizing etc..
For more complex fields when retrieving data using the Toolset REST API it will provide additional information in the results in a custom toolset_meta property.
But the raw values—as stored in wp_postmeta—are also returned in the standard meta property.
You can both read and write the raw custom field values directly using the native WP REST API, you shouldn't need to use either the Toolset REST API (which doesn't support writing) nor the WC REST API (which may not support unrecognised custom fields, I don't know).
We had been using the WC rest interface without luck, stumbled on the native Toolset one, and missed that it was read only. We're tweaking things here to use the WP api for the remaining custom field writes that we need to be able to do.