0
votes

I woocommerce you can create Attributes, like Color These attributes can have terms, like red, green, white. Later on, you can add these attributes to a product.

I know how to add these attributes by means of the API, like described here: http://woothemes.github.io/woocommerce-rest-api-docs/#create-a-product-attribute

I've been searching for hours, but there seems to be no way to add terms with the API. Am I missing something?

3

3 Answers

0
votes

You add terms with the Update A Product api, here:

You make a PUT request: /wc-api/v3/products/<id>

In the request body you send: {"product":{"categories":[...],"tages":[...]}}

0
votes

Since WooCommerce 2.5 you have new endpoint for adding attributes term. Just look at the documentation.

http://woothemes.github.io/woocommerce-rest-api-docs/#product-attribute-terms

For example for creating term for the specific attribute you can POST to endpoint

/wc-api/v3/products/attributes/<attribute_id>/terms

JSON message:

{
  "product_attribute_term": {
    "name": "Black"
  }
}
0
votes

It accepts the attribute slug/taxonomy name; Just use this one:

example.com/wp-json/wc/v3/products?attribute=pa_compatible-for&attribute_term=249

I know it's not documented properly! Have a good time.