WooCommerce-REST-API-Client-Library icon indicating copy to clipboard operation
WooCommerce-REST-API-Client-Library copied to clipboard

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

Open harunthuo opened this issue 10 years ago • 6 comments

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?

harunthuo avatar Oct 07 '15 09:10 harunthuo

Same issue on V2. Have also raised a ticket.

ghost avatar Oct 07 '15 09:10 ghost

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

jackgregory avatar Oct 07 '15 09:10 jackgregory

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') );

ghost avatar Oct 07 '15 09:10 ghost

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

mikylucky avatar Nov 13 '15 17:11 mikylucky

@mikylucky check out this thread:

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

harunthuo avatar Nov 14 '15 06:11 harunthuo

Cool, thanks!

mikylucky avatar Nov 14 '15 07:11 mikylucky