Add coupon type check when adding new coupon
This commit is contained in:
parent
d278896d31
commit
7e73f621c8
|
@ -243,6 +243,10 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
|
||||
$coupon_data = wp_parse_args( $data, $defaults );
|
||||
|
||||
if ( ! in_array( $coupon_data['type'], array_keys( wc_get_coupon_types() ) ) {
|
||||
return new WP_Error( 'woocommerce_api_invalid_coupon_type', __( 'Invalid coupon type', 'woocommerce'), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$new_coupon = array(
|
||||
'post_title' => $coupon_code,
|
||||
'post_content' => '',
|
||||
|
|
Loading…
Reference in New Issue