WC_REST_Setting_Options_Controller::get_countries_and_states
Returns a list of countries and states for use in the base location setting.
Метод класса: WC_REST_Setting_Options_Controller{}
Хуков нет.
Возвращает
Массив. Array of states and countries.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_countries_and_states();
Список изменений
| С версии 3.0.7 | Введена. |
Код WC_REST_Setting_Options_Controller::get_countries_and_states() WC REST Setting Options Controller::get countries and states WC 10.9.4
private function get_countries_and_states() {
$countries = WC()->countries->get_countries();
if ( ! $countries ) {
return array();
}
$output = array();
foreach ( $countries as $key => $value ) {
$states = WC()->countries->get_states( $key );
if ( $states ) {
foreach ( $states as $state_key => $state_value ) {
$output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value;
}
} else {
$output[ $key ] = $value;
}
}
return $output;
}