PHP Class WC_Countries

The WooCommerce countries class stores country/state data.
Author: WooThemes
Show file Open project: woocommerce/woocommerce Class Usage Examples

Public Properties

Property Type Description
$address_formats Array of address formats for locales
$locale Array of locales

Public Methods

Method Description
__get ( mixed $key ) : mixed Auto-load in-accessible properties on demand.
country_dropdown_options ( string $selected_country = '', string $selected_state = '', boolean $escape = false ) Outputs the list of countries and states for use in dropdown boxes.
estimated_for_prefix ( $country_code = '' ) : string Prefix certain countries with 'the'
ex_tax_or_vat ( ) : string Include the Ex Tax label.
get_address_fields ( mixed $country = '', string $type = 'billing_' ) : array Apply locale and get address fields.
get_address_formats ( ) : array Get country address formats.
get_allowed_countries ( ) : array Get the allowed countries for the store.
get_allowed_country_states ( ) : array Get allowed country states.
get_base_city ( ) : string Get the base city for the store.
get_base_country ( ) : string Get the base country for the store.
get_base_postcode ( ) : string Get the base postcode for the store.
get_base_state ( ) : string Get the base state for the store.
get_continent_code_for_country ( string $cc ) : string Get continent code for a country code.
get_continents ( ) : array Get all continents.
get_countries ( ) : array Get all countries.
get_country_locale ( ) : array Get country locale settings.
get_country_locale_field_selectors ( ) : array Get JS selectors for fields which are shown/hidden depending on the locale.
get_default_address_fields ( ) : array Returns the fields we show by default. This can be filtered later on.
get_european_union_countries ( $type = '' ) : string[] Gets an array of countries in the EU.
get_formatted_address ( array $args = [] ) : string Get country address format.
get_shipping_countries ( ) : array Get the countries you ship to.
get_shipping_country_states ( ) : array Get shipping country states.
get_states ( string $cc = null ) : array Get the states for a country.
inc_tax_or_vat ( ) : string Include the Inc Tax label.
load_country_states ( ) Load the states.
shipping_to_prefix ( $country_code = '' ) : string Gets the correct string for shipping - either 'to the' or 'to'
tax_or_vat ( ) : string Correctly name tax in some countries VAT on the frontend.

Private Methods

Method Description
trim_formatted_address_line ( string $line ) : string Trim white space and commas off a line.

Method Details

__get() public method

Auto-load in-accessible properties on demand.
public __get ( mixed $key ) : mixed
$key mixed
return mixed

country_dropdown_options() public method

Outputs the list of countries and states for use in dropdown boxes.
public country_dropdown_options ( string $selected_country = '', string $selected_state = '', boolean $escape = false )
$selected_country string (default: '')
$selected_state string (default: '')
$escape boolean (default: false)

estimated_for_prefix() public method

Prefix certain countries with 'the'
public estimated_for_prefix ( $country_code = '' ) : string
return string

ex_tax_or_vat() public method

Include the Ex Tax label.
public ex_tax_or_vat ( ) : string
return string

get_address_fields() public method

Apply locale and get address fields.
public get_address_fields ( mixed $country = '', string $type = 'billing_' ) : array
$country mixed (default: '')
$type string (default: 'billing_')
return array

get_address_formats() public method

Get country address formats.
public get_address_formats ( ) : array
return array

get_allowed_countries() public method

Get the allowed countries for the store.
public get_allowed_countries ( ) : array
return array

get_allowed_country_states() public method

Get allowed country states.
public get_allowed_country_states ( ) : array
return array

get_base_city() public method

Get the base city for the store.
public get_base_city ( ) : string
return string

get_base_country() public method

Get the base country for the store.
public get_base_country ( ) : string
return string

get_base_postcode() public method

Get the base postcode for the store.
public get_base_postcode ( ) : string
return string

get_base_state() public method

Get the base state for the store.
public get_base_state ( ) : string
return string

get_continent_code_for_country() public method

Get continent code for a country code.
Since: 2.6.0
public get_continent_code_for_country ( string $cc ) : string
$cc string string
return string

get_continents() public method

Get all continents.
public get_continents ( ) : array
return array

get_countries() public method

Get all countries.
public get_countries ( ) : array
return array

get_country_locale() public method

Get country locale settings.
public get_country_locale ( ) : array
return array

get_country_locale_field_selectors() public method

Get JS selectors for fields which are shown/hidden depending on the locale.

get_default_address_fields() public method

Returns the fields we show by default. This can be filtered later on.
public get_default_address_fields ( ) : array
return array

get_european_union_countries() public method

MC (monaco) and IM (isle of man, part of UK) also use VAT.
public get_european_union_countries ( $type = '' ) : string[]
$type Type of countries to retrieve. Blank for EU member countries. eu_vat for EU VAT countries.
return string[]

get_formatted_address() public method

Get country address format.
public get_formatted_address ( array $args = [] ) : string
$args array (default: array())
return string address

get_shipping_countries() public method

Get the countries you ship to.
public get_shipping_countries ( ) : array
return array

get_shipping_country_states() public method

Get shipping country states.

get_states() public method

Get the states for a country.
public get_states ( string $cc = null ) : array
$cc string country code
return array of states

inc_tax_or_vat() public method

Include the Inc Tax label.
public inc_tax_or_vat ( ) : string
return string

load_country_states() public method

Load the states.
public load_country_states ( )

shipping_to_prefix() public method

Gets the correct string for shipping - either 'to the' or 'to'
public shipping_to_prefix ( $country_code = '' ) : string
return string

tax_or_vat() public method

Correctly name tax in some countries VAT on the frontend.
public tax_or_vat ( ) : string
return string

Property Details

$address_formats public property

Array of address formats for locales
public $address_formats

$locale public property

Array of locales
public $locale