Skip to content

Commit

Permalink
Force array type for valid states (woocommerce#4975)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley authored and jonny-bull committed Dec 16, 2021
1 parent 7ae4b3c commit 67d2e6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/StoreApi/Schemas/BillingAddressSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function get_item_response( $address ) {
if ( ( $address instanceof \WC_Customer || $address instanceof \WC_Order ) ) {
$billing_country = $address->get_billing_country();
$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 ) ) {
$billing_state = '';
Expand Down
2 changes: 1 addition & 1 deletion src/StoreApi/Schemas/ShippingAddressSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get_item_response( $address ) {

$shipping_country = $address->get_shipping_country();
$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 ) ) {
$shipping_state = '';
Expand Down

0 comments on commit 67d2e6a

Please sign in to comment.