title: How to programatically set the category for a new Woocommerce Product Creation?
body: <p>The solution presented here allows me to easily create "Categories" for a wordpress post:</p>
  
  <pre><code>//Check if category already exists
  $cat_ID = get_cat_ID( $category );
  
  //If it doesn't exist create new category
  if($cat_ID == 0) {
          $cat_name = array('cat_name' =&gt; $category);
      wp_insert_category($cat_name);
  }
  
  //Get ID of category again incase a new one has been created
  $new_cat_ID = get_cat_ID($category);
  
  // Create post object
  $new_post = array(
      'post_title' =&gt; $headline,
      'post_content' =&gt; $body,
      'post_excerpt' =&gt; $excerpt,
      'post_date' =&gt; $date,
      'post_date_gmt' =&gt; $date,
      'post_status' =&gt; 'publish',
      'post_author' =&gt; 1,
      'post_category' =&gt; array($new_cat_ID)
  );
  
  // Insert the post into the database
  wp_insert_post( $new_post );
  </code></pre>
  
  <p>However, Woocommerce doesn't recognise these categories. Woocommerce categories are stored somewhere else. How can I programmatically create the categories for woocommerce and what is the correct way to assign it to a new post?</p>