WC_Countries::get_allowed_countries
Get countries that the store sells to.
Метод класса: WC_Countries{}
Хуки из метода
Возвращает
Массив.
Использование
$WC_Countries = new WC_Countries(); $WC_Countries->get_allowed_countries();
Код WC_Countries::get_allowed_countries() WC Countries::get allowed countries WC 10.5.2
public function get_allowed_countries() {
$countries = $this->countries;
$allowed_countries = get_option( 'woocommerce_allowed_countries' );
if ( 'all_except' === $allowed_countries ) {
$except_countries = get_option( 'woocommerce_all_except_countries', array() );
if ( $except_countries ) {
foreach ( $except_countries as $country ) {
unset( $countries[ $country ] );
}
}
} elseif ( 'specific' === $allowed_countries ) {
$countries = array();
$raw_countries = get_option( 'woocommerce_specific_allowed_countries', array() );
if ( $raw_countries ) {
foreach ( $raw_countries as $country ) {
$countries[ $country ] = $this->countries[ $country ];
}
}
}
/**
* Filter the list of allowed selling countries.
*
* @since 3.3.0
* @param array $countries
*/
return apply_filters( 'woocommerce_countries_allowed_countries', $countries );
}