WC_Countries::get_states
Get the states for a country.
Method of the class: WC_Countries{}
Hooks from the method
Returns
false|array. of states
Usage
$WC_Countries = new WC_Countries(); $WC_Countries->get_states( $cc );
- $cc(string)
- Country code.
Default:null
WC_Countries::get_states() WC Countries::get states code WC 11.2.1
public function get_states( $cc = null ) {
$locale = $this->get_cache_locale();
if ( ! isset( $this->geo_cache['states'][ $locale ] ) ) {
if ( isset( $this->geo_cache_building['states'][ $locale ] ) ) {
return is_null( $cc ) ? array() : false;
}
$this->geo_cache_building['states'][ $locale ] = true;
try {
/**
* Allows filtering of country states in WC.
*
* @since 1.5.3
*
* @param array $states
*/
$this->geo_cache['states'][ $locale ] = apply_filters( 'woocommerce_states', include WC()->plugin_path() . '/i18n/states.php' );
} finally {
unset( $this->geo_cache_building['states'][ $locale ] );
}
}
if ( ! is_null( $cc ) ) {
return isset( $this->geo_cache['states'][ $locale ][ $cc ] ) ? $this->geo_cache['states'][ $locale ][ $cc ] : false;
} else {
return $this->geo_cache['states'][ $locale ];
}
}