WC_Countries::get_country_locale()publicWC 1.0

Get country locale settings.

These locales override the default country selections after a country is chosen.

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

Возвращает

Массив.

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

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

Код WC_Countries::get_country_locale() WC 9.4.2

public function get_country_locale() {
	if ( empty( $this->locale ) ) {
		$this->locale = apply_filters(
			'woocommerce_get_country_locale',
			array(
				'AE' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'required' => false,
					),
				),
				'AF' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'AL' => array(
					'state' => array(
						'label' => __( 'County', 'woocommerce' ),
					),
				),
				'AO' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'AT' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'AU' => array(
					'city'     => array(
						'label' => __( 'Suburb', 'woocommerce' ),
					),
					'postcode' => array(
						'label' => __( 'Postcode', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'State', 'woocommerce' ),
					),
				),
				'AX' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'BA' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'label'    => __( 'Canton', 'woocommerce' ),
						'required' => false,
						'hidden'   => true,
					),
				),
				'BD' => array(
					'postcode' => array(
						'required' => false,
					),
					'state'    => array(
						'label' => __( 'District', 'woocommerce' ),
					),
				),
				'BE' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'BG' => array(
					'state' => array(
						'required' => false,
					),
				),
				'BH' => array(
					'postcode' => array(
						'required' => false,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'BI' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'BO' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'BS' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'BZ' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'required' => false,
					),
				),
				'CA' => array(
					'postcode' => array(
						'label' => __( 'Postal code', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'CH' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'label'    => __( 'Canton', 'woocommerce' ),
						'required' => false,
					),
				),
				'CL' => array(
					'city'     => array(
						'required' => true,
					),
					'postcode' => array(
						'required' => false,
						// Hidden for stores within Chile. @see https://github.com/woocommerce/woocommerce/issues/36546.
						'hidden'   => 'CL' === $this->get_base_country(),
					),
					'state'    => array(
						'label' => __( 'Region', 'woocommerce' ),
					),
				),
				'CN' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'CO' => array(
					'postcode' => array(
						'required' => false,
					),
					'state'    => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'CR' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'CW' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'required' => false,
					),
				),
				'CZ' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'DE' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
					),
				),
				'DK' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'DO' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'EC' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'EE' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'ET' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'FI' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'FR' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'GG' => array(
					'state' => array(
						'required' => false,
						'label'    => __( 'Parish', 'woocommerce' ),
					),
				),
				'GH' => array(
					'postcode' => array(
						'required' => false,
					),
					'state'    => array(
						'label' => __( 'Region', 'woocommerce' ),
					),
				),
				'GP' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'GF' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'GR' => array(
					'state' => array(
						'required' => false,
					),
				),
				'GT' => array(
					'postcode' => array(
						'required' => false,
					),
					'state'    => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'HK' => array(
					'postcode' => array(
						'required' => false,
					),
					'city'     => array(
						'label' => __( 'Town / District', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'Region', 'woocommerce' ),
					),
				),
				'HN' => array(
					'state' => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'HU' => array(
					'last_name'  => array(
						'class'    => array( 'form-row-first' ),
						'priority' => 10,
					),
					'first_name' => array(
						'class'    => array( 'form-row-last' ),
						'priority' => 20,
					),
					'postcode'   => array(
						'class'    => array( 'form-row-first', 'address-field' ),
						'priority' => 65,
					),
					'city'       => array(
						'class' => array( 'form-row-last', 'address-field' ),
					),
					'address_1'  => array(
						'priority' => 71,
					),
					'address_2'  => array(
						'priority' => 72,
					),
					'state'      => array(
						'label'    => __( 'County', 'woocommerce' ),
						'required' => false,
					),
				),
				'ID' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'IE' => array(
					'postcode' => array(
						'required' => false,
						'label'    => __( 'Eircode', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'County', 'woocommerce' ),
					),
				),
				'IS' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'IL' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'IM' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'IN' => array(
					'postcode' => array(
						'label' => __( 'PIN Code', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'State', 'woocommerce' ),
					),
				),
				'IR' => array(
					'state'     => array(
						'priority' => 50,
					),
					'city'      => array(
						'priority' => 60,
					),
					'address_1' => array(
						'priority' => 70,
					),
					'address_2' => array(
						'priority' => 80,
					),
				),
				'IT' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => true,
						'label'    => __( 'Province', 'woocommerce' ),
					),
				),
				'JM' => array(
					'city'     => array(
						'label' => __( 'Town / City / Post Office', 'woocommerce' ),
					),
					'postcode' => array(
						'required' => false,
						'label'    => __( 'Postal Code', 'woocommerce' ),
					),
					'state'    => array(
						'required' => true,
						'label'    => __( 'Parish', 'woocommerce' ),
					),
				),
				'JP' => array(
					'last_name'  => array(
						'class'    => array( 'form-row-first' ),
						'priority' => 10,
					),
					'first_name' => array(
						'class'    => array( 'form-row-last' ),
						'priority' => 20,
					),
					'postcode'   => array(
						'class'    => array( 'form-row-first', 'address-field' ),
						'priority' => 65,
					),
					'state'      => array(
						'label'    => __( 'Prefecture', 'woocommerce' ),
						'class'    => array( 'form-row-last', 'address-field' ),
						'priority' => 66,
					),
					'city'       => array(
						'priority' => 67,
					),
					'address_1'  => array(
						'priority' => 68,
					),
					'address_2'  => array(
						'priority' => 69,
					),
				),
				'KN' => array(
					'postcode' => array(
						'required' => false,
						'label'    => __( 'Postal code', 'woocommerce' ),
					),
					'state'    => array(
						'required' => true,
						'label'    => __( 'Parish', 'woocommerce' ),
					),
				),
				'KR' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'KW' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'LV' => array(
					'state' => array(
						'label'    => __( 'Municipality', 'woocommerce' ),
						'required' => false,
					),
				),
				'LB' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'MF' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'MQ' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'MT' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'MZ' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'NI' => array(
					'state' => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'NL' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'NG' => array(
					'postcode' => array(
						'label'    => __( 'Postcode', 'woocommerce' ),
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'label' => __( 'State', 'woocommerce' ),
					),
				),
				'NZ' => array(
					'postcode' => array(
						'label' => __( 'Postcode', 'woocommerce' ),
					),
					'state'    => array(
						'required' => false,
						'label'    => __( 'Region', 'woocommerce' ),
					),
				),
				'NO' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'NP' => array(
					'state'    => array(
						'label' => __( 'State / Zone', 'woocommerce' ),
					),
					'postcode' => array(
						'required' => false,
					),
				),
				'PA' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'PL' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'PR' => array(
					'city'  => array(
						'label' => __( 'Municipality', 'woocommerce' ),
					),
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'PT' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'PY' => array(
					'state' => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'RE' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'RO' => array(
					'state' => array(
						'label'    => __( 'County', 'woocommerce' ),
						'required' => true,
					),
				),
				'RS' => array(
					'city'     => array(
						'required' => true,
					),
					'postcode' => array(
						'required' => true,
					),
					'state'    => array(
						'label'    => __( 'District', 'woocommerce' ),
						'required' => false,
					),
				),
				'RW' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'SG' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
					'city'  => array(
						'required' => false,
					),
				),
				'SK' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'SI' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'SR' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'SV' => array(
					'state' => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'ES' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'LI' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'LK' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'LU' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'MD' => array(
					'state' => array(
						'label' => __( 'Municipality / District', 'woocommerce' ),
					),
				),
				'SE' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'TR' => array(
					'postcode' => array(
						'priority' => 65,
					),
					'state'    => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'UG' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'city'     => array(
						'label'    => __( 'Town / Village', 'woocommerce' ),
						'required' => true,
					),
					'state'    => array(
						'label'    => __( 'District', 'woocommerce' ),
						'required' => true,
					),
				),
				'US' => array(
					'postcode' => array(
						'label' => __( 'ZIP Code', 'woocommerce' ),
					),
					'state'    => array(
						'label' => __( 'State', 'woocommerce' ),
					),
				),
				'UY' => array(
					'state' => array(
						'label' => __( 'Department', 'woocommerce' ),
					),
				),
				'GB' => array(
					'postcode' => array(
						'label' => __( 'Postcode', 'woocommerce' ),
					),
					'state'    => array(
						'label'    => __( 'County', 'woocommerce' ),
						'required' => false,
					),
				),
				'ST' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
					'state'    => array(
						'label' => __( 'District', 'woocommerce' ),
					),
				),
				'VN' => array(
					'state'     => array(
						'required' => false,
						'hidden'   => true,
					),
					'postcode'  => array(
						'priority' => 65,
						'required' => false,
						'hidden'   => false,
					),
					'address_2' => array(
						'required' => false,
						'hidden'   => false,
					),
				),
				'WS' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'YT' => array(
					'state' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
				'ZA' => array(
					'state' => array(
						'label' => __( 'Province', 'woocommerce' ),
					),
				),
				'ZW' => array(
					'postcode' => array(
						'required' => false,
						'hidden'   => true,
					),
				),
			)
		);

		$this->locale = array_intersect_key( $this->locale, array_merge( $this->get_allowed_countries(), $this->get_shipping_countries() ) );

		// Default Locale Can be filtered to override fields in get_address_fields(). Countries with no specific locale will use default.
		$this->locale['default'] = apply_filters( 'woocommerce_get_country_locale_default', $this->get_default_address_fields() );

		// Filter default AND shop base locales to allow overrides via a single function. These will be used when changing countries on the checkout.
		if ( ! isset( $this->locale[ $this->get_base_country() ] ) ) {
			$this->locale[ $this->get_base_country() ] = $this->locale['default'];
		}

		$this->locale['default']                   = apply_filters( 'woocommerce_get_country_locale_base', $this->locale['default'] );
		$this->locale[ $this->get_base_country() ] = apply_filters( 'woocommerce_get_country_locale_base', $this->locale[ $this->get_base_country() ] );
	}

	return $this->locale;
}