Add check of $raw_countries before the foreach in WC_Countries

This commit is contained in:
kreamweb 2016-05-14 11:02:05 +02:00
parent 1f2cda5a49
commit 0a2c0af5ff
1 changed files with 14 additions and 8 deletions

View File

@ -231,9 +231,11 @@ class WC_Countries {
$raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' );
if ( $raw_countries ) {
foreach ( $raw_countries as $country ) { foreach ( $raw_countries as $country ) {
$countries[ $country ] = $this->countries[ $country ]; $countries[ $country ] = $this->countries[ $country ];
} }
}
return apply_filters( 'woocommerce_countries_shipping_countries', $countries ); return apply_filters( 'woocommerce_countries_shipping_countries', $countries );
} }
@ -251,11 +253,13 @@ class WC_Countries {
$raw_countries = get_option( 'woocommerce_specific_allowed_countries' ); $raw_countries = get_option( 'woocommerce_specific_allowed_countries' );
if ( $raw_countries ) {
foreach ( $raw_countries as $country ) { foreach ( $raw_countries as $country ) {
if ( isset( $this->states[ $country ] ) ) { if ( isset( $this->states[ $country ] ) ) {
$states[ $country ] = $this->states[ $country ]; $states[ $country ] = $this->states[ $country ];
} }
} }
}
return apply_filters( 'woocommerce_countries_allowed_country_states', $states ); return apply_filters( 'woocommerce_countries_allowed_country_states', $states );
} }
@ -277,11 +281,13 @@ class WC_Countries {
$raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' );
if ( $raw_countries ) {
foreach ( $raw_countries as $country ) { foreach ( $raw_countries as $country ) {
if ( ! empty( $this->states[ $country ] ) ) { if ( ! empty( $this->states[ $country ] ) ) {
$states[ $country ] = $this->states[ $country ]; $states[ $country ] = $this->states[ $country ];
} }
} }
}
return apply_filters( 'woocommerce_countries_shipping_country_states', $states ); return apply_filters( 'woocommerce_countries_shipping_country_states', $states );
} }