From 0a2c0af5ffb097ba7aa4e6f6a14799eb34af7f6a Mon Sep 17 00:00:00 2001 From: kreamweb Date: Sat, 14 May 2016 11:02:05 +0200 Subject: [PATCH] Add check of $raw_countries before the foreach in WC_Countries --- includes/class-wc-countries.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php index 3a1fe5d53bc..55e5c1edb7c 100644 --- a/includes/class-wc-countries.php +++ b/includes/class-wc-countries.php @@ -231,8 +231,10 @@ class WC_Countries { $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); - foreach ( $raw_countries as $country ) { - $countries[ $country ] = $this->countries[ $country ]; + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + $countries[ $country ] = $this->countries[ $country ]; + } } return apply_filters( 'woocommerce_countries_shipping_countries', $countries ); @@ -251,9 +253,11 @@ class WC_Countries { $raw_countries = get_option( 'woocommerce_specific_allowed_countries' ); - foreach ( $raw_countries as $country ) { - if ( isset( $this->states[ $country ] ) ) { - $states[ $country ] = $this->states[ $country ]; + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + if ( isset( $this->states[ $country ] ) ) { + $states[ $country ] = $this->states[ $country ]; + } } } @@ -277,9 +281,11 @@ class WC_Countries { $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); - foreach ( $raw_countries as $country ) { - if ( ! empty( $this->states[ $country ] ) ) { - $states[ $country ] = $this->states[ $country ]; + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + if ( ! empty( $this->states[ $country ] ) ) { + $states[ $country ] = $this->states[ $country ]; + } } }