Add coupon type check when adding new coupon

This commit is contained in:
Gerhard 2014-03-06 07:49:01 +02:00
parent d278896d31
commit 7e73f621c8
1 changed files with 4 additions and 0 deletions

View File

@ -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' => '',