Force array type for valid states (https://github.com/woocommerce/woocommerce-blocks/pull/4975)
This commit is contained in:
parent
a1046eb95e
commit
4b0f975707
|
@ -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 = '';
|
||||||
|
|
|
@ -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 = '';
|
||||||
|
|
Loading…
Reference in New Issue