WC_Countries::get_allowed_country_states │ public │ WC 1.0

Get allowed country states.

Method of the class: WC_Countries{}

Returns

array.

Usage

$WC_Countries = new WC_Countries();
$WC_Countries->get_allowed_country_states();

WC_Countries::get_allowed_country_states() code WC 11.2.1

public function get_allowed_country_states() {
	if ( get_option( 'woocommerce_allowed_countries' ) !== 'specific' ) {
		return $this->read_geo_property( 'states' );
	}

	$states = array();

	$raw_countries = get_option( 'woocommerce_specific_allowed_countries' );

	if ( $raw_countries ) {
		$all_states = $this->read_geo_property( 'states' );

		foreach ( $raw_countries as $country ) {
			if ( isset( $all_states[ $country ] ) ) {
				$states[ $country ] = $all_states[ $country ];
			}
		}
	}

	return apply_filters( 'woocommerce_countries_allowed_country_states', $states );
}