title: How to use add_product function for variations in Woocommerce
body: <p>I am trying to add product variations using the add_product() function from woocommerce.</p>
  
  <p>But everytime I add the variation product. It just adds the parent product and not the variation.</p>
  
  <pre><code>$product_id = 40;
  $variation_id = 42;
  $quantity = 1;
  $variation_name = color;
  $variation_option = red;
  
  $args = array(
      'attribute_'.$variation_name =&gt; $variation_option,
  );
  
  $order = wc_create_order();
  $order-&gt;add_product( get_product( $product_id ), $quantity, $args );
  </code></pre>
  
  <p>I also have tried this which also doesn't work</p>
  
  <pre><code>$order-&gt;add_product( get_product( $variation_id ), $quantity, $args );
  </code></pre>
  
  <p>I have doubled checked the variation id, attribute, name and option.</p>