Change comma separate data to arrays
This commit is contained in:
parent
88d6e064fa
commit
6ddbc7e6ee
|
@ -225,8 +225,8 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
'type' => 'fixed_cart',
|
||||
'amount' => 0,
|
||||
'individual_use' => 'no',
|
||||
'product_ids' => '',
|
||||
'exclude_product_ids' => '',
|
||||
'product_ids' => array(),
|
||||
'exclude_product_ids' => array(),
|
||||
'usage_limit' => '',
|
||||
'usage_limit_per_user' => '',
|
||||
'limit_usage_to_x_items' => '',
|
||||
|
@ -234,11 +234,11 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
'expiry_date' => '',
|
||||
'apply_before_tax' => 'yes',
|
||||
'free_shipping' => 'no',
|
||||
'product_categories' => '',
|
||||
'exclude_product_categories' => '',
|
||||
'product_categories' => array(),
|
||||
'exclude_product_categories' => array(),
|
||||
'exclude_sale_items' => 'no',
|
||||
'minimum_amount' => '',
|
||||
'customer_email' => '',
|
||||
'customer_email' => array(),
|
||||
);
|
||||
|
||||
$coupon_data = wp_parse_args( $data, $defaults );
|
||||
|
@ -265,8 +265,8 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
update_post_meta( $id, 'discount_type', $coupon_data['type'] );
|
||||
update_post_meta( $id, 'coupon_amount', wc_format_decimal( $coupon_data['amount'] ) );
|
||||
update_post_meta( $id, 'individual_use', $coupon_data['individual_use'] );
|
||||
update_post_meta( $id, 'product_ids', implode( ',', array_filter( array_map( 'intval', explode( ',', $coupon_data['product_ids'] ) ) ) ) );
|
||||
update_post_meta( $id, 'exclude_product_ids', implode( ',', array_filter( array_map( 'intval', explode( ',', $coupon_data['exclude_product_ids'] ) ) ) ) );
|
||||
update_post_meta( $id, 'product_ids', array_filter( array_map( 'intval', $coupon_data['product_ids'] ) ) );
|
||||
update_post_meta( $id, 'exclude_product_ids', array_filter( array_map( 'intval', $coupon_data['exclude_product_ids'] ) ) );
|
||||
update_post_meta( $id, 'usage_limit', absint( $coupon_data['usage_limit'] ) );
|
||||
update_post_meta( $id, 'usage_limit_per_user', absint( $coupon_data['usage_limit_per_user'] ) );
|
||||
update_post_meta( $id, 'limit_usage_to_x_items', absint( $coupon_data['limit_usage_to_x_items'] ) );
|
||||
|
@ -274,11 +274,11 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
update_post_meta( $id, 'expiry_date', wc_clean( $coupon_data['expiry_date'] ) );
|
||||
update_post_meta( $id, 'apply_before_tax', wc_clean( $coupon_data['apply_before_tax'] ) );
|
||||
update_post_meta( $id, 'free_shipping', wc_clean( $coupon_data['free_shipping'] ) );
|
||||
update_post_meta( $id, 'product_categories', implode( ',', array_filter( array_map( 'intval', explode( ',', $coupon_data['product_categories'] ) ) ) ) );
|
||||
update_post_meta( $id, 'exclude_product_categories', implode( ',', array_filter( array_map( 'intval', explode( ',', $coupon_data['exclude_product_categories'] ) ) ) ) );
|
||||
update_post_meta( $id, 'product_categories', array_filter( array_map( 'intval', $coupon_data['product_categories'] ) ) );
|
||||
update_post_meta( $id, 'exclude_product_categories', array_filter( array_map( 'intval', $coupon_data['exclude_product_categories'] ) ) );
|
||||
update_post_meta( $id, 'exclude_sale_items', wc_clean( $coupon_data['exclude_sale_items'] ) );
|
||||
update_post_meta( $id, 'minimum_amount', wc_format_decimal( $coupon_data['minimum_amount'] ) );
|
||||
update_post_meta( $id, 'customer_email', implode( ',', array_filter( array_map( 'trim', explode( ',', $coupon_data['customer_email'] ) ) ) ) );
|
||||
update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $coupon_data['customer_email'] ) ) );
|
||||
|
||||
do_action( 'woocommerce_api_create_coupon', $id, $data );
|
||||
|
||||
|
|
Loading…
Reference in New Issue