is it possible to add a category to a woocommerce post?
I am creating my products as follows:
// creates woocommerce product
$product = array(
'post_title' => $name,
'post_content' => '',
'post_status' => 'publish',
'post_author' => $current_user->ID,
'post_type' =>'product'
);
// Insert the post into the database
$product_ID = wp_insert_post($product);
I have a category called "Tree" where I have to add the above product to. I have tried the following but without succes. Is there some special way to add a category?
wp_set_object_terms($productID, array('Tree'), 'product_cat');