kloon / WooCommerce-REST-API-Client-Library

A PHP wrapper for the WooCommerce REST API
GNU General Public License v3.0
356 stars 175 forks source link

Creating categories and tags using the woocommerce REST api issue(V3) #130

Open harunthuo opened 9 years ago

harunthuo commented 9 years ago

Looks like the new V3 does not allow creating of product categories and tags when creating a product using the api:

print_r( $client->products->create( array( 'title' => 'product_name','sku' => 'sku_value', 'type' => 'simple', 'regular_price' => '1000', 'short_description'=>'short description', 'categories' => Array ('category1','category2','category3' ), 'tags'=> array('product_tag'))));

all the other properties are still created but not categories and tags. returns an empty array:

["categories"]=> array(0) { } ["tags"]=> array(0) { }

so question is: how are categories and tags created using the REST api V3?

ghost commented 9 years ago

Same issue on V2. Have also raised a ticket.

jackgregory commented 9 years ago

@aggrogg @harunthuo In write mode you need to send category IDs.

ghost commented 9 years ago

Thanks Jack- let's hope it's released soon.

I have posted a temp workaround to add categories / tags.

http://wordpress.stackexchange.com/questions/137501/how-to-add-product-in-woocommerce-with-php-code

Just directly update the post in the database i.e.

update_post_meta( $post_id, 'post_category', array('foo') );

mikylucky commented 8 years ago

Seems there is no endpoint to create categories by API. I would need it too

harunthuo commented 8 years ago

@mikylucky check out this thread:

https://github.com/woothemes/woocommerce-rest-api-docs/issues/20#issuecomment-146188582

mikylucky commented 8 years ago

Cool, thanks!