From 30f20b81decfd0c1d5f1a3a9f609b02ec666f8c9 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Wed, 24 May 2017 14:09:09 +0200 Subject: [PATCH] Make state validation less stricter for keys --- includes/class-wc-checkout.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 739dcc48183..39939eab8b0 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -657,12 +657,12 @@ class WC_Checkout { if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) { $valid_state_values = array_flip( array_map( 'strtolower', $valid_states ) ); - // Convert value to key if set if ( isset( $valid_state_values[ strtolower( $data[ $key ] ) ] ) ) { + // With this part we consider state value to be valid as well, convert it to the state key for the valid_states check below. $data[ $key ] = $valid_state_values[ strtolower( $data[ $key ] ) ]; } - if ( ! in_array( $data[ $key ], array_keys( $valid_states ) ) ) { + if ( ! in_array( strtoupper( $data[ $key ] ), array_keys( $valid_states ) ) ) { /* translators: 1: state field 2: valid states */ $errors->add( 'validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '' . $field_label . '', implode( ', ', $valid_states ) ) ); }