title: Applying programmatically a coupon to an Order in WooCommerce3
body: <p>I'm developing a plugin that creates an order directly (no cart) and applies a coupon. In version 3.0 of the woo API the function <code>add_coupon()</code> has been deprecated in favour of a <code>WC_Order_Item_Coupon</code> object you add to the order.</p>
  
  <p>Create the coupon </p>
  
  <pre><code>$coupon = new WC_Order_Item_Coupon();
  $coupon-&gt;set_props(array('code' =&gt; $coupon, 'discount' =&gt; $discount_total, 
  'discount_tax' =&gt; 0));
  $coupon-&gt;save();
  </code></pre>
  
  <p>This is successful. I can validate by calling <code>$coupon-&gt;get_discount()</code>.</p>
  
  <p>I then add the coupon to the order and recalculate totals:</p>
  
  <pre><code>$order-&gt;add_item($item);
  $order-&gt;calculate_totals($discount_total);
  $order-&gt;save(); 
  </code></pre>
  
  <p>Logging into wp-admin I can see the order with coupon code visible. However, the coupon has had no effect on line items or total. </p>
  
  <p>Have a misunderstood how api v3.0 intends us to handle coupons?</p>