WC_Countries::get_shipping_countries()publicWC 1.0

Get countries that the store ships to.

Метод класса: WC_Countries{}

Хуки из метода

Возвращает

Массив.

Использование

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

Код WC_Countries::get_shipping_countries() WC 8.7.0

public function get_shipping_countries() {
	// If shipping is disabled, return an empty array.
	if ( 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ) {
		return array();
	}

	// Default to selling countries.
	$countries = $this->get_allowed_countries();

	// All indicates that all countries are allowed, regardless of where you sell to.
	if ( 'all' === get_option( 'woocommerce_ship_to_countries' ) ) {
		$countries = $this->countries;
	} elseif ( 'specific' === get_option( 'woocommerce_ship_to_countries' ) ) {
		$countries     = array();
		$raw_countries = get_option( 'woocommerce_specific_ship_to_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_shipping_countries', $countries );
}