diff --git a/includes/class-payment.php b/includes/class-payment.php index 972663a..e814394 100644 --- a/includes/class-payment.php +++ b/includes/class-payment.php @@ -513,7 +513,7 @@ public function validate_fields() { if ( $this->upi_address === 'show_handle' ) { $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*$/i'; } - if ( ! preg_match( $regex, sanitize_text_field( $_POST['customer_upiwc_address'] ) ) && in_array( $this->upi_address, [ 'show', 'show_handle' ] ) && $this->require_upi === 'yes' ) { + if ( in_array( $this->upi_address, [ 'show', 'show_handle' ] ) && $this->require_upi === 'yes' &&! preg_match( $regex, sanitize_text_field( $_POST['customer_upiwc_address'] ) ) ) { wc_add_notice( __( 'Please enter a valid UPI Address!', 'upi-qr-code-payment-for-woocommerce' ), 'error' ); return false; }