I've been trying to add tags to products via:
data = {
product: {
tags: [
"mirrored"
]
}
}
woocommerce.put("products/#{product_id}", data).parsed_response
Firstly, I needed the extra "product" json in there because otherwise I get:
{"errors"=>[{"code"=>"woocommerce_api_missing_product_data", "message"=>"No product data specified to edit product"}]}
I can verify the code works for non-array updates, for example:
data = {
product: {
"weight": "12345",
}
}
works well.
I have tried a number of variations to "data" to see if any would successfully add a tag. For example, I attempted to do it like this:
data = {
product: {
"tags": [
{
"id": "2",
"slug": "mirrored"
},
]
}
}
Each time the tags field does not change. I have tried similar approaches with the "attributes" field and had the same problem - they would not update.
The documentation speaks about Product Tag updating, but to my understanding this refers to creating/changing/deleting the tags themselves?
How can I successfully edit the tags that a product has?
I've been trying to add tags to products via: data = { product: { tags: [ "mirrored" ] } } woocommerce.put("products/#{product_id}", data).parsed_response
Firstly, I needed the extra "product" json in there because otherwise I get: {"errors"=>[{"code"=>"woocommerce_api_missing_product_data", "message"=>"No product data specified to edit product"}]}
I can verify the code works for non-array updates, for example: data = { product: { "weight": "12345", } } works well.
I have tried a number of variations to "data" to see if any would successfully add a tag. For example, I attempted to do it like this: data = { product: { "tags": [ { "id": "2", "slug": "mirrored" }, ] } }
Each time the tags field does not change. I have tried similar approaches with the "attributes" field and had the same problem - they would not update.
The documentation speaks about Product Tag updating, but to my understanding this refers to creating/changing/deleting the tags themselves? How can I successfully edit the tags that a product has?