WC_Countries::get_states PHP Метод

get_states() публичный Метод

Get the states for a country.
public get_states ( string $cc = null ) : array
$cc string country code
Результат array of states
    public function get_states($cc = null)
    {
        if (empty($this->states)) {
            $this->load_country_states();
        }
        if (!is_null($cc)) {
            return isset($this->states[$cc]) ? $this->states[$cc] : false;
        } else {
            return $this->states;
        }
    }

Usage Example

?>
</label>
								<input type="text" name="billing_postcode" id="billing_postcode" value="<?php 
if (isset($customer)) {
    echo $customer['billing_postcode'];
}
?>
" tabindex="1" />
							</div>
							<div class="field_block">
								<?php 
global $woocommerce;
$countries_obj = new WC_Countries();
$countries = $countries_obj->__get('countries');
$default_country = $countries_obj->get_base_country();
$default_county_states = $countries_obj->get_states($default_country);
if (isset($customer['billing_state'])) {
    $default_state = $customer['billing_state'];
} else {
    $default_state = '';
}
woocommerce_form_field('billing_state', array('type' => 'select', 'class' => array('chzn-drop'), 'label' => $state, 'placeholder' => __('Select a State'), 'options' => $default_county_states, 'default' => $default_state));
?>
							</div>
							<div style="clear:both;"></div>
						</div>

						<div class="woocommerce" style="text-align:center;">
							<a class="checkout-button button alt wc-forward" href="#" onclick="jQuery('form.cart').submit();return(false);"><?php 
echo $addcart;
?>
All Usage Examples Of WC_Countries::get_states