Update programatically ONE attribute of Woocommerce product
We have a Woocommerce store with many products, and all of them have around 8 attributes (size, color, etc.)
There’s one attribute that we regularly update and we do that importing a CSV. It’s very slow because we change all other attributes that actually are not changed, but you have to update all of them. Right now, WC does not allow to change only one attribute when importing: it’s all or nothing.
I tried updating via the API, by using:
/wp-json/wc/v3/products/586960/
and sending a PUT like this:
{
"attributes": [
{
"id": 7,
"options": [ "Choice 1, Choice 2" ]
}]
}
What happened is that it wiped all other attributes.
I checked if there’s an endpoint to a particular attribute inside a product, like product/<id>/attribute/<id>
but it didn’t work.
Is there a way to update, via import or API, only that particular attribute without deleting all the others or having to import a CSV w/all the attributes or send a huge JSON with all the information?
Thanks!
Leave an answer