diff --git a/includes/admin/class-edd-notices.php b/includes/admin/class-edd-notices.php index db3033a2a28..3993bab7153 100644 --- a/includes/admin/class-edd-notices.php +++ b/includes/admin/class-edd-notices.php @@ -137,6 +137,10 @@ public function show_notices() { break; case 'discount_invalid_code': $notices['error']['edd-discount-invalid-code'] = __( 'The discount code entered is invalid; only alphanumeric characters are allowed, please try again.', 'easy-digital-downloads' ); + break; + case 'discount_invalid_amount' : + $notices['error']['edd-discount-invalid-amount'] = __( 'The discount amount must be a valid percentage or numeric flat amount. Please try again.', 'easy-digital-downloads' ); + break; } } diff --git a/includes/admin/discounts/discount-actions.php b/includes/admin/discounts/discount-actions.php index 73f49cec143..720eddf6219 100755 --- a/includes/admin/discounts/discount-actions.php +++ b/includes/admin/discounts/discount-actions.php @@ -45,6 +45,11 @@ function edd_add_discount( $data ) { edd_die(); } + if ( ! is_numeric( $data['amount'] ) ) { + wp_redirect( add_query_arg( 'edd-message', 'discount_invalid_amount' ) ); + edd_die(); + } + foreach ( $data as $key => $value ) { if ( $key === 'products' || $key === 'excluded-products' ) { @@ -112,6 +117,11 @@ function edd_edit_discount( $data ) { wp_die( __( 'You do not have permission to edit discount codes', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); } + if ( empty( $data['amount'] ) || ! is_numeric( $data['amount'] ) ) { + wp_redirect( add_query_arg( 'edd-message', 'discount_invalid_amount' ) ); + edd_die(); + } + // Setup the discount code details $discount = array();