title: Create a coupon programmatically since WooCommerce 3+
body: <p>I add coupons at woocommerce with this code programmatically.</p>
  <pre><code>    if(empty($coupon_post)){
  
          $coupon = array(
              'post_title'    =&gt; $coupon_code,
              'post_content'  =&gt; '',
              'post_status'   =&gt; 'publish',
              'post_author'   =&gt; 1,
              'post_type'     =&gt; 'shop_coupon'
          );
  
          $new_coupon_id = wp_insert_post( $coupon );
  
          // Add meta
  update_post_meta( $new_coupon_id, 'discount_type', $discount_type );
  update_post_meta( $new_coupon_id, 'coupon_amount', $amount );
  update_post_meta( $new_coupon_id, 'individual_use', 'yes' );
  update_post_meta( $new_coupon_id, 'product_ids', '' );
  update_post_meta( $new_coupon_id, 'exclude_product_ids', '' );
  update_post_meta( $new_coupon_id, 'usage_limit', '' );
  update_post_meta( $new_coupon_id, 'expiry_date', '' );
  update_post_meta( $new_coupon_id, 'apply_before_tax', 'yes' );
  update_post_meta( $new_coupon_id, 'free_shipping', 'no' );      
  update_post_meta( $new_coupon_id, 'exclude_sale_items', 'no' );     
  update_post_meta( $new_coupon_id, 'free_shipping', 'no' );      
  update_post_meta( $new_coupon_id, 'product_categories', '' );       
  update_post_meta( $new_coupon_id, 'exclude_product_categories', '' );       
  update_post_meta( $new_coupon_id, 'minimum_amount', '' );       
  update_post_meta( $new_coupon_id, 'customer_email', '' ); 
      }
  </code></pre>
  <p>But it says always the usage_limit = 1.</p>
  <p>I add additional this code to update:</p>
  <pre><code>add_action( 'save_post_shop_coupon', 'my_child_after_coupon_save', 10, 3 );
  
  function my_child_after_coupon_save( $post_id, $post, $update ) {
     update_post_meta( $post_id, 'usage_limit', '');
  }
  
  </code></pre>
  <p>But it doesn't work first.But if I open the coupon in the backend and update without any changes. The usage limit is set to unlimited.</p>
  <p>How can trigger this, that I needn't to open all coupons.</p>