title: How to set category to product woocommerce
body: <p>is it possible to add a category to a woocommerce post?</p>
  
  <p>I am creating my products as follows:</p>
  
  <pre><code>// creates woocommerce product 
  $product = array(
      'post_title'    =&gt; $name,
      'post_content'  =&gt; '',
      'post_status'   =&gt; 'publish',
      'post_author'   =&gt; $current_user-&gt;ID,
      'post_type'     =&gt;'product'
  );
  
  // Insert the post into the database
  $product_ID = wp_insert_post($product);
  </code></pre>
  
  <p>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?</p>
  
  <pre><code>wp_set_object_terms($productID, array('Tree'), 'product_cat');
  </code></pre>