$uniquenom, 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'shop_coupon' ); $new_coupon_id = wp_insert_post( $coupon ); update_post_meta( $new_coupon_id, 'discount_type', $coutype ); update_post_meta( $new_coupon_id, 'coupon_amount', $discount ); update_post_meta( $new_coupon_id, 'usage_limit', $ulimit ); update_post_meta( $new_coupon_id, 'usage_limit_per_user', $ulimitperu ); update_post_meta( $new_coupon_id, 'minimum_amount', $minamount ); update_post_meta( $new_coupon_id, 'expiry_date', $expiry ); update_post_meta( $new_coupon_id, 'individual_use', $individ ); update_post_meta( $new_coupon_id, 'free_shipping', $friship ); update_post_meta( $new_coupon_id, 'exclude_sale_items', $exsale ); update_post_meta( $new_coupon_id, 'maximum_amount', $maxamount ); $x++; } wp_die(); // this is required to terminate immediately and return a proper response } } else { /* Post notification on admin dashboard if WooCommerce not found */ function aucfwc_woo_err_notice() { $note = __( 'WooCommerce Not Found! Auto Coupons for WooCommerce cannot run without WooCommerce.', 'auto-coupons-woo' ); printf( '

%1$s

', esc_html( $note ) ); } add_action( 'admin_notices', 'aucfwc_woo_err_notice' ); } }