woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 74 forks source link

Can't update a products tags or attributes via API #31

Closed HStromfelt closed 7 years ago

HStromfelt commented 7 years ago

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?

claudiosanches commented 7 years ago

Not an issue with this REST API lib, you should try check the WooCommerce REST API docs for the version you are using: https://woocommerce.github.io/woocommerce-rest-api-docs/