This commit is contained in:
Mike Jolley 2021-10-20 16:29:21 +01:00 committed by GitHub
parent a1046eb95e
commit 4b0f975707
2 changed files with 2 additions and 2 deletions

View File

@ -95,7 +95,7 @@ class BillingAddressSchema extends AbstractAddressSchema {
if ( ( $address instanceof \WC_Customer || $address instanceof \WC_Order ) ) { if ( ( $address instanceof \WC_Customer || $address instanceof \WC_Order ) ) {
$billing_country = $address->get_billing_country(); $billing_country = $address->get_billing_country();
$billing_state = $address->get_billing_state(); $billing_state = $address->get_billing_state();
$valid_states = wc()->countries->get_states( $billing_country ); $valid_states = array_filter( (array) wc()->countries->get_states( $billing_country ) );
if ( ! empty( $billing_state ) && count( $valid_states ) && ! in_array( $billing_state, $valid_states, true ) ) { if ( ! empty( $billing_state ) && count( $valid_states ) && ! in_array( $billing_state, $valid_states, true ) ) {
$billing_state = ''; $billing_state = '';

View File

@ -44,7 +44,7 @@ class ShippingAddressSchema extends AbstractAddressSchema {
$shipping_country = $address->get_shipping_country(); $shipping_country = $address->get_shipping_country();
$shipping_state = $address->get_shipping_state(); $shipping_state = $address->get_shipping_state();
$valid_states = wc()->countries->get_states( $shipping_country ); $valid_states = array_filter( (array) wc()->countries->get_states( $shipping_country ) );
if ( ! empty( $shipping_state ) && count( $valid_states ) && ! in_array( $shipping_state, $valid_states, true ) ) { if ( ! empty( $shipping_state ) && count( $valid_states ) && ! in_array( $shipping_state, $valid_states, true ) ) {
$shipping_state = ''; $shipping_state = '';