WC_Countries::get_allowed_countries()
Get countries that the store sells to.
Method of the class: WC_Countries{}
Hooks from the method
Return
Array
.
Usage
$WC_Countries = new WC_Countries(); $WC_Countries->get_allowed_countries();
WC_Countries::get_allowed_countries() WC Countries::get allowed countries code WC 9.4.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 ); }