autoship_generated_virtual_wc_coupon

(src\coupons.php) Within the autoship_generate_virtual_wc_coupon() function. This filter can be used to adjust a virtual coupon as it’s generated and perform other tasks related to that coupon. Takes the coupon and coupon data as parameters. 

Example

$args = wp_parse_args( $coupon_data, array(
    'code'          => '',
    'description'   => '',
    'discount_type' => '',
    'amount'        => 0
  ) );

  $coupon = new WC_Coupon();
  $coupon->set_code( $args['code'] );
  $coupon->set_description( $args['description'] );
  $coupon->set_discount_type( $args['discount_type'] );
  $coupon->set_amount( $args['amount'] );
  $coupon->set_virtual( true );

  return apply_filters( 'autoship_generated_virtual_wc_coupon', $coupon, $coupon_data );

Still need help? Contact Us Contact Us