2011-08-09 15:16:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2011-08-10 17:11:11 +00:00
|
|
|
* WooCommerce countries
|
2011-08-09 15:16:18 +00:00
|
|
|
*
|
2011-08-10 17:11:11 +00:00
|
|
|
* The WooCommerce countries class stores country/state data.
|
2011-08-09 15:16:18 +00:00
|
|
|
*
|
2011-08-10 17:11:11 +00:00
|
|
|
* @class woocommerce_countries
|
|
|
|
* @package WooCommerce
|
|
|
|
* @category Class
|
|
|
|
* @author WooThemes
|
2011-08-09 15:16:18 +00:00
|
|
|
*/
|
2011-08-10 17:11:11 +00:00
|
|
|
class woocommerce_countries {
|
2011-08-09 15:16:18 +00:00
|
|
|
|
2011-11-17 10:40:32 +00:00
|
|
|
var $countries;
|
|
|
|
var $states;
|
2011-12-15 23:24:02 +00:00
|
|
|
var $locale;
|
|
|
|
var $address_formats;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
2011-11-17 10:40:32 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
function __construct() {
|
|
|
|
|
|
|
|
$this->countries = array(
|
|
|
|
'AF' => __('Afghanistan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'AX' => __('Aland Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AL' => __('Albania', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'DZ' => __('Algeria', 'woothemes'),
|
|
|
|
'AS' => __('American Samoa', 'woothemes'),
|
|
|
|
'AD' => __('Andorra', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AO' => __('Angola', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'AI' => __('Anguilla', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AQ' => __('Antarctica', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'AG' => __('Antigua and Barbuda', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AR' => __('Argentina', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'AM' => __('Armenia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AW' => __('Aruba', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'AU' => __('Australia', 'woothemes'),
|
|
|
|
'AT' => __('Austria', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'AZ' => __('Azerbaijan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BS' => __('Bahamas', 'woothemes'),
|
|
|
|
'BH' => __('Bahrain', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'BD' => __('Bangladesh', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BB' => __('Barbados', 'woothemes'),
|
|
|
|
'BY' => __('Belarus', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'BE' => __('Belgium', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BZ' => __('Belize', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'BJ' => __('Benin', 'woothemes'),
|
|
|
|
'BM' => __('Bermuda', 'woothemes'),
|
|
|
|
'BT' => __('Bhutan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BO' => __('Bolivia', 'woothemes'),
|
|
|
|
'BA' => __('Bosnia and Herzegovina', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'BW' => __('Botswana', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BR' => __('Brazil', 'woothemes'),
|
|
|
|
'IO' => __('British Indian Ocean Territory', 'woothemes'),
|
|
|
|
'VG' => __('British Virgin Islands', 'woothemes'),
|
|
|
|
'BN' => __('Brunei', 'woothemes'),
|
|
|
|
'BG' => __('Bulgaria', 'woothemes'),
|
|
|
|
'BF' => __('Burkina Faso', 'woothemes'),
|
|
|
|
'BI' => __('Burundi', 'woothemes'),
|
|
|
|
'KH' => __('Cambodia', 'woothemes'),
|
|
|
|
'CM' => __('Cameroon', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CA' => __('Canada', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'CV' => __('Cape Verde', 'woothemes'),
|
|
|
|
'KY' => __('Cayman Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CF' => __('Central African Republic', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'TD' => __('Chad', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CL' => __('Chile', 'woothemes'),
|
|
|
|
'CN' => __('China', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'CX' => __('Christmas Island', 'woothemes'),
|
|
|
|
'CC' => __('Cocos (Keeling) Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CO' => __('Colombia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'KM' => __('Comoros', 'woothemes'),
|
|
|
|
'CG' => __('Congo (Brazzaville)', 'woothemes'),
|
|
|
|
'CD' => __('Congo (Kinshasa)', 'woothemes'),
|
|
|
|
'CK' => __('Cook Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CR' => __('Costa Rica', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'HR' => __('Croatia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CU' => __('Cuba', 'woothemes'),
|
|
|
|
'CY' => __('Cyprus', 'woothemes'),
|
|
|
|
'CZ' => __('Czech Republic', 'woothemes'),
|
|
|
|
'DK' => __('Denmark', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'DJ' => __('Djibouti', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'DM' => __('Dominica', 'woothemes'),
|
|
|
|
'DO' => __('Dominican Republic', 'woothemes'),
|
|
|
|
'EC' => __('Ecuador', 'woothemes'),
|
|
|
|
'EG' => __('Egypt', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SV' => __('El Salvador', 'woothemes'),
|
|
|
|
'GQ' => __('Equatorial Guinea', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'ER' => __('Eritrea', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'EE' => __('Estonia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'ET' => __('Ethiopia', 'woothemes'),
|
|
|
|
'FK' => __('Falkland Islands', 'woothemes'),
|
|
|
|
'FO' => __('Faroe Islands', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'FJ' => __('Fiji', 'woothemes'),
|
|
|
|
'FI' => __('Finland', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'FR' => __('France', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'GF' => __('French Guiana', 'woothemes'),
|
|
|
|
'PF' => __('French Polynesia', 'woothemes'),
|
|
|
|
'TF' => __('French Southern Territories', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GA' => __('Gabon', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'GM' => __('Gambia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GE' => __('Georgia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'DE' => __('Germany', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GH' => __('Ghana', 'woothemes'),
|
|
|
|
'GI' => __('Gibraltar', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'GR' => __('Greece', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GL' => __('Greenland', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'GD' => __('Grenada', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GP' => __('Guadeloupe', 'woothemes'),
|
|
|
|
'GU' => __('Guam', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'GT' => __('Guatemala', 'woothemes'),
|
|
|
|
'GG' => __('Guernsey', 'woothemes'),
|
|
|
|
'GN' => __('Guinea', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'GW' => __('Guinea-Bissau', 'woothemes'),
|
|
|
|
'GY' => __('Guyana', 'woothemes'),
|
|
|
|
'HT' => __('Haiti', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'HN' => __('Honduras', 'woothemes'),
|
|
|
|
'HK' => __('Hong Kong', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'HU' => __('Hungary', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'IS' => __('Iceland', 'woothemes'),
|
|
|
|
'IN' => __('India', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'ID' => __('Indonesia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'IR' => __('Iran', 'woothemes'),
|
|
|
|
'IQ' => __('Iraq', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'IE' => __('Ireland', 'woothemes'),
|
|
|
|
'IM' => __('Isle of Man', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'IL' => __('Israel', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'IT' => __('Italy', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'CI' => __('Ivory Coast', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'JM' => __('Jamaica', 'woothemes'),
|
|
|
|
'JP' => __('Japan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'JE' => __('Jersey', 'woothemes'),
|
|
|
|
'JO' => __('Jordan', 'woothemes'),
|
|
|
|
'KZ' => __('Kazakhstan', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'KE' => __('Kenya', 'woothemes'),
|
|
|
|
'KI' => __('Kiribati', 'woothemes'),
|
|
|
|
'KW' => __('Kuwait', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'KG' => __('Kyrgyzstan', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'LA' => __('Laos', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'LV' => __('Latvia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'LB' => __('Lebanon', 'woothemes'),
|
|
|
|
'LS' => __('Lesotho', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'LR' => __('Liberia', 'woothemes'),
|
|
|
|
'LY' => __('Libya', 'woothemes'),
|
|
|
|
'LI' => __('Liechtenstein', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'LT' => __('Lithuania', 'woothemes'),
|
|
|
|
'LU' => __('Luxembourg', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'MO' => __('Macao S.A.R., China', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'MK' => __('Macedonia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'MG' => __('Madagascar', 'woothemes'),
|
|
|
|
'MW' => __('Malawi', 'woothemes'),
|
|
|
|
'MY' => __('Malaysia', 'woothemes'),
|
|
|
|
'MV' => __('Maldives', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'ML' => __('Mali', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'MT' => __('Malta', 'woothemes'),
|
|
|
|
'MH' => __('Marshall Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'MQ' => __('Martinique', 'woothemes'),
|
|
|
|
'MR' => __('Mauritania', 'woothemes'),
|
|
|
|
'MU' => __('Mauritius', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'YT' => __('Mayotte', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'MX' => __('Mexico', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'FM' => __('Micronesia', 'woothemes'),
|
|
|
|
'MD' => __('Moldova', 'woothemes'),
|
|
|
|
'MC' => __('Monaco', 'woothemes'),
|
|
|
|
'MN' => __('Mongolia', 'woothemes'),
|
|
|
|
'ME' => __('Montenegro', 'woothemes'),
|
|
|
|
'MS' => __('Montserrat', 'woothemes'),
|
|
|
|
'MA' => __('Morocco', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'MZ' => __('Mozambique', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'MM' => __('Myanmar', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'NA' => __('Namibia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'NR' => __('Nauru', 'woothemes'),
|
|
|
|
'NP' => __('Nepal', 'woothemes'),
|
|
|
|
'NL' => __('Netherlands', 'woothemes'),
|
|
|
|
'AN' => __('Netherlands Antilles', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'NC' => __('New Caledonia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'NZ' => __('New Zealand', 'woothemes'),
|
|
|
|
'NI' => __('Nicaragua', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'NE' => __('Niger', 'woothemes'),
|
|
|
|
'NG' => __('Nigeria', 'woothemes'),
|
|
|
|
'NU' => __('Niue', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'NF' => __('Norfolk Island', 'woothemes'),
|
|
|
|
'KP' => __('North Korea', 'woothemes'),
|
|
|
|
'MP' => __('Northern Mariana Islands', 'woothemes'),
|
|
|
|
'NO' => __('Norway', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'OM' => __('Oman', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'PK' => __('Pakistan', 'woothemes'),
|
|
|
|
'PW' => __('Palau', 'woothemes'),
|
|
|
|
'PS' => __('Palestinian Territory', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'PA' => __('Panama', 'woothemes'),
|
|
|
|
'PG' => __('Papua New Guinea', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'PY' => __('Paraguay', 'woothemes'),
|
|
|
|
'PE' => __('Peru', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'PH' => __('Philippines', 'woothemes'),
|
|
|
|
'PN' => __('Pitcairn', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'PL' => __('Poland', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'PT' => __('Portugal', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'PR' => __('Puerto Rico', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'QA' => __('Qatar', 'woothemes'),
|
|
|
|
'RE' => __('Reunion', 'woothemes'),
|
|
|
|
'RO' => __('Romania', 'woothemes'),
|
|
|
|
'RU' => __('Russia', 'woothemes'),
|
|
|
|
'RW' => __('Rwanda', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'BL' => __('Saint Barthélemy', 'woothemes'),
|
|
|
|
'SH' => __('Saint Helena', 'woothemes'),
|
|
|
|
'KN' => __('Saint Kitts and Nevis', 'woothemes'),
|
|
|
|
'LC' => __('Saint Lucia', 'woothemes'),
|
|
|
|
'MF' => __('Saint Martin (French part)', 'woothemes'),
|
|
|
|
'PM' => __('Saint Pierre and Miquelon', 'woothemes'),
|
|
|
|
'VC' => __('Saint Vincent and the Grenadines', 'woothemes'),
|
|
|
|
'WS' => __('Samoa', 'woothemes'),
|
|
|
|
'SM' => __('San Marino', 'woothemes'),
|
|
|
|
'ST' => __('Sao Tome and Principe', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SA' => __('Saudi Arabia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SN' => __('Senegal', 'woothemes'),
|
|
|
|
'RS' => __('Serbia', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SC' => __('Seychelles', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SL' => __('Sierra Leone', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SG' => __('Singapore', 'woothemes'),
|
|
|
|
'SK' => __('Slovakia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SI' => __('Slovenia', 'woothemes'),
|
|
|
|
'SB' => __('Solomon Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SO' => __('Somalia', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'ZA' => __('South Africa', 'woothemes'),
|
|
|
|
'GS' => __('South Georgia/Sandwich Islands', 'woothemes'),
|
|
|
|
'KR' => __('South Korea', 'woothemes'),
|
|
|
|
'ES' => __('Spain', 'woothemes'),
|
|
|
|
'LK' => __('Sri Lanka', 'woothemes'),
|
|
|
|
'SD' => __('Sudan', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SR' => __('Suriname', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SJ' => __('Svalbard and Jan Mayen', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'SZ' => __('Swaziland', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'SE' => __('Sweden', 'woothemes'),
|
|
|
|
'CH' => __('Switzerland', 'woothemes'),
|
|
|
|
'SY' => __('Syria', 'woothemes'),
|
|
|
|
'TW' => __('Taiwan', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'TJ' => __('Tajikistan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'TZ' => __('Tanzania', 'woothemes'),
|
|
|
|
'TH' => __('Thailand', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'TL' => __('Timor-Leste', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'TG' => __('Togo', 'woothemes'),
|
|
|
|
'TK' => __('Tokelau', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'TO' => __('Tonga', 'woothemes'),
|
|
|
|
'TT' => __('Trinidad and Tobago', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'TN' => __('Tunisia', 'woothemes'),
|
|
|
|
'TR' => __('Turkey', 'woothemes'),
|
|
|
|
'TM' => __('Turkmenistan', 'woothemes'),
|
|
|
|
'TC' => __('Turks and Caicos Islands', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'TV' => __('Tuvalu', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'VI' => __('U.S. Virgin Islands', 'woothemes'),
|
|
|
|
'USAF' => __('US Armed Forces', 'woothemes'),
|
2011-11-23 00:44:11 +00:00
|
|
|
'UM' => __('US Minor Outlying Islands', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'UG' => __('Uganda', 'woothemes'),
|
|
|
|
'UA' => __('Ukraine', 'woothemes'),
|
|
|
|
'AE' => __('United Arab Emirates', 'woothemes'),
|
|
|
|
'GB' => __('United Kingdom', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'US' => __('United States', 'woothemes'),
|
|
|
|
'UY' => __('Uruguay', 'woothemes'),
|
|
|
|
'UZ' => __('Uzbekistan', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'VU' => __('Vanuatu', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'VA' => __('Vatican', 'woothemes'),
|
|
|
|
'VE' => __('Venezuela', 'woothemes'),
|
|
|
|
'VN' => __('Vietnam', 'woothemes'),
|
|
|
|
'WF' => __('Wallis and Futuna', 'woothemes'),
|
2011-12-15 23:24:02 +00:00
|
|
|
'EH' => __('Western Sahara', 'woothemes'),
|
2011-11-17 10:40:32 +00:00
|
|
|
'YE' => __('Yemen', 'woothemes'),
|
|
|
|
'ZM' => __('Zambia', 'woothemes'),
|
|
|
|
'ZW' => __('Zimbabwe', 'woothemes')
|
|
|
|
);
|
2011-12-15 23:24:02 +00:00
|
|
|
|
2011-11-17 10:40:32 +00:00
|
|
|
$this->states = array(
|
|
|
|
'AU' => array(
|
|
|
|
'ACT' => __('Australian Capital Territory', 'woothemes') ,
|
|
|
|
'NSW' => __('New South Wales', 'woothemes') ,
|
|
|
|
'NT' => __('Northern Territory', 'woothemes') ,
|
|
|
|
'QLD' => __('Queensland', 'woothemes') ,
|
|
|
|
'SA' => __('South Australia', 'woothemes') ,
|
|
|
|
'TAS' => __('Tasmania', 'woothemes') ,
|
|
|
|
'VIC' => __('Victoria', 'woothemes') ,
|
|
|
|
'WA' => __('Western Australia', 'woothemes')
|
2011-08-09 15:16:18 +00:00
|
|
|
),
|
2011-12-15 19:22:15 +00:00
|
|
|
'AT' => array(),
|
2011-11-17 10:40:32 +00:00
|
|
|
'BR' => array(
|
|
|
|
'AM' => __('Amazonas', 'woothemes'),
|
|
|
|
'AC' => __('Acre', 'woothemes'),
|
|
|
|
'AL' => __('Alagoas', 'woothemes'),
|
|
|
|
'AP' => __('Amapá', 'woothemes'),
|
|
|
|
'CE' => __('Ceará', 'woothemes'),
|
|
|
|
'DF' => __('Distrito federal', 'woothemes'),
|
|
|
|
'ES' => __('Espirito santo', 'woothemes'),
|
|
|
|
'MA' => __('Maranhão', 'woothemes'),
|
|
|
|
'PR' => __('Paraná', 'woothemes'),
|
|
|
|
'PE' => __('Pernambuco', 'woothemes'),
|
|
|
|
'PI' => __('Piauí', 'woothemes'),
|
|
|
|
'RN' => __('Rio grande do norte', 'woothemes'),
|
|
|
|
'RS' => __('Rio grande do sul', 'woothemes'),
|
|
|
|
'RO' => __('Rondônia', 'woothemes'),
|
|
|
|
'RR' => __('Roraima', 'woothemes'),
|
|
|
|
'SC' => __('Santa catarina', 'woothemes'),
|
|
|
|
'SE' => __('Sergipe', 'woothemes'),
|
|
|
|
'TO' => __('Tocantins', 'woothemes'),
|
|
|
|
'PA' => __('Pará', 'woothemes'),
|
|
|
|
'BH' => __('Bahia', 'woothemes'),
|
|
|
|
'GO' => __('Goiás', 'woothemes'),
|
|
|
|
'MT' => __('Mato grosso', 'woothemes'),
|
|
|
|
'MS' => __('Mato grosso do sul', 'woothemes'),
|
|
|
|
'RJ' => __('Rio de janeiro', 'woothemes'),
|
|
|
|
'SP' => __('São paulo', 'woothemes'),
|
|
|
|
'RS' => __('Rio grande do sul', 'woothemes'),
|
|
|
|
'MG' => __('Minas gerais', 'woothemes'),
|
|
|
|
'PB' => __('Paraiba', 'woothemes'),
|
2011-08-09 15:16:18 +00:00
|
|
|
),
|
2011-11-17 10:40:32 +00:00
|
|
|
'CA' => array(
|
|
|
|
'AB' => __('Alberta', 'woothemes') ,
|
|
|
|
'BC' => __('British Columbia', 'woothemes') ,
|
|
|
|
'MB' => __('Manitoba', 'woothemes') ,
|
|
|
|
'NB' => __('New Brunswick', 'woothemes') ,
|
|
|
|
'NF' => __('Newfoundland', 'woothemes') ,
|
|
|
|
'NT' => __('Northwest Territories', 'woothemes') ,
|
|
|
|
'NS' => __('Nova Scotia', 'woothemes') ,
|
|
|
|
'NU' => __('Nunavut', 'woothemes') ,
|
|
|
|
'ON' => __('Ontario', 'woothemes') ,
|
|
|
|
'PE' => __('Prince Edward Island', 'woothemes') ,
|
|
|
|
'PQ' => __('Quebec', 'woothemes') ,
|
|
|
|
'SK' => __('Saskatchewan', 'woothemes') ,
|
|
|
|
'YT' => __('Yukon Territory', 'woothemes')
|
2011-08-09 15:16:18 +00:00
|
|
|
),
|
2011-12-15 19:22:15 +00:00
|
|
|
'CZ' => array(),
|
2011-12-15 01:14:47 +00:00
|
|
|
'DE' => array(),
|
2011-12-15 19:22:15 +00:00
|
|
|
'DK' => array(),
|
2011-12-15 23:24:02 +00:00
|
|
|
'FI' => array(),
|
|
|
|
'FR' => array(),
|
|
|
|
'HK' => array(
|
|
|
|
'HONG KONG' => __('Hong Kong Island', 'woothemes'),
|
|
|
|
'KOWLOONG' => __('Kowloong', 'woothemes'),
|
|
|
|
'NEW TERRITORIES' => __('New Territories', 'woothemes')
|
|
|
|
),
|
2011-12-16 21:19:56 +00:00
|
|
|
'HU' => array(),
|
|
|
|
'IS' => array(),
|
|
|
|
'IL' => array(),
|
|
|
|
'NL' => array(),
|
|
|
|
'NZ' => array(),
|
|
|
|
'NO' => array(),
|
|
|
|
'PL' => array(),
|
|
|
|
'SG' => array(),
|
|
|
|
'SK' => array(),
|
|
|
|
'SI' => array(),
|
|
|
|
'LK' => array(),
|
|
|
|
'SE' => array(),
|
2011-11-17 10:40:32 +00:00
|
|
|
'US' => array(
|
|
|
|
'AL' => __('Alabama', 'woothemes') ,
|
|
|
|
'AK' => __('Alaska', 'woothemes') ,
|
|
|
|
'AZ' => __('Arizona', 'woothemes') ,
|
|
|
|
'AR' => __('Arkansas', 'woothemes') ,
|
|
|
|
'CA' => __('California', 'woothemes') ,
|
|
|
|
'CO' => __('Colorado', 'woothemes') ,
|
|
|
|
'CT' => __('Connecticut', 'woothemes') ,
|
|
|
|
'DE' => __('Delaware', 'woothemes') ,
|
|
|
|
'DC' => __('District Of Columbia', 'woothemes') ,
|
|
|
|
'FL' => __('Florida', 'woothemes') ,
|
|
|
|
'GA' => __('Georgia', 'woothemes') ,
|
|
|
|
'HI' => __('Hawaii', 'woothemes') ,
|
|
|
|
'ID' => __('Idaho', 'woothemes') ,
|
|
|
|
'IL' => __('Illinois', 'woothemes') ,
|
|
|
|
'IN' => __('Indiana', 'woothemes') ,
|
|
|
|
'IA' => __('Iowa', 'woothemes') ,
|
|
|
|
'KS' => __('Kansas', 'woothemes') ,
|
|
|
|
'KY' => __('Kentucky', 'woothemes') ,
|
|
|
|
'LA' => __('Louisiana', 'woothemes') ,
|
|
|
|
'ME' => __('Maine', 'woothemes') ,
|
|
|
|
'MD' => __('Maryland', 'woothemes') ,
|
|
|
|
'MA' => __('Massachusetts', 'woothemes') ,
|
|
|
|
'MI' => __('Michigan', 'woothemes') ,
|
|
|
|
'MN' => __('Minnesota', 'woothemes') ,
|
|
|
|
'MS' => __('Mississippi', 'woothemes') ,
|
|
|
|
'MO' => __('Missouri', 'woothemes') ,
|
|
|
|
'MT' => __('Montana', 'woothemes') ,
|
|
|
|
'NE' => __('Nebraska', 'woothemes') ,
|
|
|
|
'NV' => __('Nevada', 'woothemes') ,
|
|
|
|
'NH' => __('New Hampshire', 'woothemes') ,
|
|
|
|
'NJ' => __('New Jersey', 'woothemes') ,
|
|
|
|
'NM' => __('New Mexico', 'woothemes') ,
|
|
|
|
'NY' => __('New York', 'woothemes') ,
|
|
|
|
'NC' => __('North Carolina', 'woothemes') ,
|
|
|
|
'ND' => __('North Dakota', 'woothemes') ,
|
|
|
|
'OH' => __('Ohio', 'woothemes') ,
|
|
|
|
'OK' => __('Oklahoma', 'woothemes') ,
|
|
|
|
'OR' => __('Oregon', 'woothemes') ,
|
|
|
|
'PA' => __('Pennsylvania', 'woothemes') ,
|
|
|
|
'RI' => __('Rhode Island', 'woothemes') ,
|
|
|
|
'SC' => __('South Carolina', 'woothemes') ,
|
|
|
|
'SD' => __('South Dakota', 'woothemes') ,
|
|
|
|
'TN' => __('Tennessee', 'woothemes') ,
|
|
|
|
'TX' => __('Texas', 'woothemes') ,
|
|
|
|
'UT' => __('Utah', 'woothemes') ,
|
|
|
|
'VT' => __('Vermont', 'woothemes') ,
|
|
|
|
'VA' => __('Virginia', 'woothemes') ,
|
|
|
|
'WA' => __('Washington', 'woothemes') ,
|
|
|
|
'WV' => __('West Virginia', 'woothemes') ,
|
|
|
|
'WI' => __('Wisconsin', 'woothemes') ,
|
|
|
|
'WY' => __('Wyoming', 'woothemes')
|
|
|
|
),
|
|
|
|
'USAF' => array(
|
|
|
|
'AA' => __('Americas', 'woothemes') ,
|
|
|
|
'AE' => __('Europe', 'woothemes') ,
|
|
|
|
'AP' => __('Pacific', 'woothemes')
|
2011-08-09 15:16:18 +00:00
|
|
|
)
|
2011-11-17 10:40:32 +00:00
|
|
|
);
|
|
|
|
}
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
/** get base country */
|
|
|
|
function get_base_country() {
|
2011-08-10 17:11:11 +00:00
|
|
|
$default = get_option('woocommerce_default_country');
|
2011-08-09 15:16:18 +00:00
|
|
|
if (strstr($default, ':')) :
|
|
|
|
$country = current(explode(':', $default));
|
|
|
|
$state = end(explode(':', $default));
|
|
|
|
else :
|
|
|
|
$country = $default;
|
|
|
|
$state = '';
|
|
|
|
endif;
|
|
|
|
|
|
|
|
return $country;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** get base state */
|
|
|
|
function get_base_state() {
|
2011-08-10 17:11:11 +00:00
|
|
|
$default = get_option('woocommerce_default_country');
|
2011-08-09 15:16:18 +00:00
|
|
|
if (strstr($default, ':')) :
|
|
|
|
$country = current(explode(':', $default));
|
|
|
|
$state = end(explode(':', $default));
|
|
|
|
else :
|
|
|
|
$country = $default;
|
|
|
|
$state = '';
|
|
|
|
endif;
|
|
|
|
|
|
|
|
return $state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** get countries we allow only */
|
|
|
|
function get_allowed_countries() {
|
|
|
|
|
2011-09-06 11:11:22 +00:00
|
|
|
$countries = $this->countries;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
2011-08-10 17:11:11 +00:00
|
|
|
if (get_option('woocommerce_allowed_countries')!=='specific') return $countries;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
$allowed_countries = array();
|
|
|
|
|
2011-08-10 17:11:11 +00:00
|
|
|
$allowed_countries_raw = get_option('woocommerce_specific_allowed_countries');
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
foreach ($allowed_countries_raw as $country) :
|
|
|
|
|
|
|
|
$allowed_countries[$country] = $countries[$country];
|
|
|
|
|
|
|
|
endforeach;
|
|
|
|
|
|
|
|
asort($allowed_countries);
|
|
|
|
|
|
|
|
return $allowed_countries;
|
|
|
|
}
|
|
|
|
|
2011-10-31 10:54:49 +00:00
|
|
|
/** Gets an array of countries in the EU */
|
|
|
|
function get_european_union_countries() {
|
|
|
|
return array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK');
|
|
|
|
}
|
|
|
|
|
2011-08-09 15:16:18 +00:00
|
|
|
/** Gets the correct string for shipping - ether 'to the' or 'to' */
|
|
|
|
function shipping_to_prefix() {
|
2011-09-06 11:11:22 +00:00
|
|
|
global $woocommerce;
|
2011-08-09 15:16:18 +00:00
|
|
|
$return = '';
|
2011-12-14 23:50:32 +00:00
|
|
|
if (in_array($woocommerce->customer->get_shipping_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ))) $return = __('to the', 'woothemes');
|
2011-08-10 17:11:11 +00:00
|
|
|
else $return = __('to', 'woothemes');
|
2011-10-31 10:54:49 +00:00
|
|
|
return apply_filters('woocommerce_countries_shipping_to_prefix', $return, $woocommerce->customer->get_shipping_country());
|
2011-08-09 15:16:18 +00:00
|
|
|
}
|
|
|
|
|
2011-10-31 10:54:49 +00:00
|
|
|
/** Prefix certain countries with 'the' */
|
2011-08-09 15:16:18 +00:00
|
|
|
function estimated_for_prefix() {
|
2011-09-06 11:11:22 +00:00
|
|
|
global $woocommerce;
|
2011-08-09 15:16:18 +00:00
|
|
|
$return = '';
|
2011-12-14 23:50:32 +00:00
|
|
|
if (in_array($this->get_base_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ))) $return = __('the', 'woothemes') . ' ';
|
|
|
|
return apply_filters('woocommerce_countries_estimated_for_prefix', $return, $this->get_base_country());
|
2011-10-31 10:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Correctly name tax in some countries VAT on the frontend */
|
|
|
|
function tax_or_vat() {
|
|
|
|
global $woocommerce;
|
|
|
|
|
2011-11-22 13:18:33 +00:00
|
|
|
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? __('VAT', 'woothemes') : __('Tax', 'woothemes');
|
2011-10-31 10:54:49 +00:00
|
|
|
|
|
|
|
return apply_filters('woocommerce_countries_tax_or_vat', $return);
|
|
|
|
}
|
|
|
|
|
2011-11-26 16:15:25 +00:00
|
|
|
function inc_tax_or_vat( $rate = false ) {
|
2011-10-31 10:54:49 +00:00
|
|
|
global $woocommerce;
|
|
|
|
|
2011-11-27 00:03:46 +00:00
|
|
|
if ( $rate > 0 || $rate === 0 ) :
|
2011-12-01 11:34:26 +00:00
|
|
|
$rate = rtrim(rtrim($rate, '0'), '.');
|
2011-11-26 16:15:25 +00:00
|
|
|
if (!$rate) $rate = 0;
|
|
|
|
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? sprintf(__('(inc. %s%% VAT)', 'woothemes'), $rate) : sprintf(__('(inc. %s%% tax)', 'woothemes'), $rate);
|
|
|
|
else :
|
|
|
|
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? __('(inc. VAT)', 'woothemes') : __('(inc. tax)', 'woothemes');
|
|
|
|
endif;
|
2011-10-31 10:54:49 +00:00
|
|
|
|
2011-11-26 16:15:25 +00:00
|
|
|
return apply_filters('woocommerce_countries_inc_tax_or_vat', $return, $rate);
|
2011-10-31 10:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ex_tax_or_vat() {
|
|
|
|
global $woocommerce;
|
|
|
|
|
|
|
|
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? __('(ex. VAT)', 'woothemes') : __('(ex. tax)', 'woothemes');
|
|
|
|
|
|
|
|
return apply_filters('woocommerce_countries_ex_tax_or_vat', $return);
|
2011-08-09 15:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** get states */
|
|
|
|
function get_states( $cc ) {
|
2011-09-06 11:11:22 +00:00
|
|
|
if (isset( $this->states[$cc] )) return $this->states[$cc];
|
2011-08-09 15:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Outputs the list of countries and states for use in dropdown boxes */
|
|
|
|
function country_dropdown_options( $selected_country = '', $selected_state = '', $escape=false ) {
|
|
|
|
|
2011-09-06 11:11:22 +00:00
|
|
|
$countries = $this->countries;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
if ( $countries ) foreach ( $countries as $key=>$value) :
|
2011-09-06 11:11:22 +00:00
|
|
|
if ( $states = $this->get_states($key) ) :
|
2011-08-09 15:16:18 +00:00
|
|
|
echo '<optgroup label="'.$value.'">';
|
|
|
|
foreach ($states as $state_key=>$state_value) :
|
|
|
|
echo '<option value="'.$key.':'.$state_key.'"';
|
|
|
|
|
|
|
|
if ($selected_country==$key && $selected_state==$state_key) echo ' selected="selected"';
|
|
|
|
|
|
|
|
echo '>'.$value.' — '. ($escape ? esc_js($state_value) : $state_value) .'</option>';
|
|
|
|
endforeach;
|
|
|
|
echo '</optgroup>';
|
|
|
|
else :
|
|
|
|
echo '<option';
|
|
|
|
if ($selected_country==$key && $selected_state=='*') echo ' selected="selected"';
|
2011-08-10 17:11:11 +00:00
|
|
|
echo ' value="'.$key.'">'. ($escape ? esc_js( __($value, 'woothemes') ) : __($value, 'woothemes') ) .'</option>';
|
2011-08-09 15:16:18 +00:00
|
|
|
endif;
|
|
|
|
endforeach;
|
|
|
|
}
|
2011-08-24 16:23:04 +00:00
|
|
|
|
|
|
|
/** Outputs the list of countries and states for use in multiselect boxes */
|
|
|
|
function country_multiselect_options( $selected_countries = '', $escape=false ) {
|
|
|
|
|
2011-09-06 11:11:22 +00:00
|
|
|
$countries = $this->countries;
|
2011-08-24 16:23:04 +00:00
|
|
|
|
|
|
|
if ( $countries ) foreach ( $countries as $key=>$value) :
|
2011-09-06 11:11:22 +00:00
|
|
|
if ( $states = $this->get_states($key) ) :
|
2011-08-24 16:23:04 +00:00
|
|
|
echo '<optgroup label="'.$value.'">';
|
|
|
|
foreach ($states as $state_key=>$state_value) :
|
|
|
|
echo '<option value="'.$key.':'.$state_key.'"';
|
|
|
|
|
|
|
|
if (isset($selected_countries[$key]) && in_array($state_key, $selected_countries[$key])) echo ' selected="selected"';
|
|
|
|
|
|
|
|
echo '>' . ($escape ? esc_js($state_value) : $state_value) .'</option>';
|
|
|
|
endforeach;
|
|
|
|
echo '</optgroup>';
|
|
|
|
else :
|
|
|
|
echo '<option';
|
|
|
|
|
|
|
|
if (isset($selected_countries[$key]) && in_array('*', $selected_countries[$key])) echo ' selected="selected"';
|
|
|
|
|
|
|
|
echo ' value="'.$key.'">'. ($escape ? esc_js( __($value, 'woothemes') ) : __($value, 'woothemes') ) .'</option>';
|
|
|
|
endif;
|
|
|
|
endforeach;
|
|
|
|
}
|
2011-12-15 23:24:02 +00:00
|
|
|
|
|
|
|
/** Get country address formats */
|
|
|
|
function get_address_format( $country = '' ) {
|
|
|
|
|
|
|
|
if (!$this->address_formats) :
|
2011-12-16 21:19:56 +00:00
|
|
|
|
|
|
|
// Common formats
|
|
|
|
$postcode_before_city = "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}";
|
|
|
|
|
|
|
|
// Define address formats
|
2011-12-15 23:24:02 +00:00
|
|
|
$this->address_formats = apply_filters('woocommerce_localisation_address_formats', array(
|
|
|
|
'default' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}",
|
|
|
|
'AU' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {state} {postcode}\n{country}",
|
2011-12-16 21:19:56 +00:00
|
|
|
'AT' => $postcode_before_city,
|
2011-12-15 23:24:02 +00:00
|
|
|
'CN' => "{country} {postcode}\n{state}, {city}, {address_2}, {address_1}\n{company}\n{name}",
|
2011-12-16 21:19:56 +00:00
|
|
|
'CZ' => $postcode_before_city,
|
|
|
|
'DE' => $postcode_before_city,
|
|
|
|
'FI' => $postcode_before_city,
|
|
|
|
'DK' => $postcode_before_city,
|
2011-12-15 23:24:02 +00:00
|
|
|
'FR' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city_upper}\n{country}",
|
2011-12-16 21:19:56 +00:00
|
|
|
'HK' => "{company}\n{first_name} {last_name_upper}\n{address_1}\n{address_2}\n{city_upper}\n{state_upper}\n{country}",
|
|
|
|
'HU' => "{name}\n{company}\n{city}\n{address_1}\n{address_2}\n{postcode}\n{country}",
|
|
|
|
'IS' => $postcode_before_city,
|
|
|
|
'IS' => $postcode_before_city,
|
|
|
|
'NL' => $postcode_before_city,
|
|
|
|
'NZ' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {postcode}\n{country}",
|
|
|
|
'NO' => $postcode_before_city,
|
|
|
|
'PL' => $postcode_before_city,
|
|
|
|
'SK' => $postcode_before_city,
|
|
|
|
'SI' => $postcode_before_city,
|
|
|
|
'ES' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}",
|
|
|
|
'SE' => $postcode_before_city,
|
|
|
|
'TR' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city} {state}\n{country}",
|
|
|
|
'US' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state} {postcode}\n{country}",
|
2011-12-15 23:24:02 +00:00
|
|
|
));
|
|
|
|
endif;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get country locale settings */
|
|
|
|
function get_country_locale() {
|
|
|
|
global $woocommerce;
|
|
|
|
|
|
|
|
if (!$this->locale) :
|
|
|
|
|
|
|
|
// Locale information used by the checkout
|
2011-12-16 21:19:56 +00:00
|
|
|
$this->locale = apply_filters('woocommerce_localisation_address_fields', array(
|
2011-12-15 23:24:02 +00:00
|
|
|
'AT' => array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode_before_city' => true,
|
2011-12-15 23:24:02 +00:00
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'CA' => array(
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('Province', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'CL' => array(
|
2011-12-16 21:19:56 +00:00
|
|
|
'city' => array(
|
2011-12-15 23:24:02 +00:00
|
|
|
'required' => false,
|
2011-12-16 21:19:56 +00:00
|
|
|
),
|
|
|
|
'state' => array(
|
2011-12-15 23:24:02 +00:00
|
|
|
'label' => __('Municipality', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'CN' => array(
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('Province', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'DE' => array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode_before_city' => true,
|
2011-12-15 23:24:02 +00:00
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'DK' => array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode_before_city' => true,
|
2011-12-15 23:24:02 +00:00
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'FI' => array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode_before_city' => true,
|
2011-12-15 23:24:02 +00:00
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'FR' => array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode_before_city' => true,
|
2011-12-15 23:24:02 +00:00
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'HK' => array(
|
|
|
|
'postcode' => array(
|
|
|
|
'required' => false
|
|
|
|
),
|
|
|
|
'city' => array(
|
|
|
|
'label' => __('Town/District', 'woothemes')
|
|
|
|
),
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('Region', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
2011-12-16 21:19:56 +00:00
|
|
|
'HU' => array(
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'IS' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'IL' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'NL' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'NZ' => array(
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'NO' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'PL' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'RO' => array(
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'SG' => array(
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'SK' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'SI' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'ES' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('Province', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'LK' => array(
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'SE' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'required' => false
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'TR' => array(
|
|
|
|
'postcode_before_city' => true,
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('Province', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
2011-12-16 15:11:41 +00:00
|
|
|
'US' => array(
|
|
|
|
'postcode' => array(
|
|
|
|
'label' => __('Zip', 'woothemes')
|
|
|
|
),
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('State', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'GB' => array(
|
|
|
|
'postcode' => array(
|
|
|
|
'label' => __('Postcode', 'woothemes')
|
|
|
|
),
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('County', 'woothemes')
|
|
|
|
)
|
|
|
|
),
|
2011-12-15 23:24:02 +00:00
|
|
|
|
2011-12-16 21:19:56 +00:00
|
|
|
));
|
2011-12-16 15:11:41 +00:00
|
|
|
|
|
|
|
$this->locale = array_intersect_key($this->locale, $this->get_allowed_countries());
|
|
|
|
|
2011-12-16 21:19:56 +00:00
|
|
|
$this->locale['default'] = apply_filters('woocommerce_localisation_default_address_fields', array(
|
2011-12-16 15:11:41 +00:00
|
|
|
'postcode' => array(
|
|
|
|
'label' => __('Postcode/Zip', 'woothemes')
|
|
|
|
),
|
|
|
|
'city' => array(
|
|
|
|
'label' => __('Town/City', 'woothemes')
|
|
|
|
),
|
|
|
|
'state' => array(
|
|
|
|
'label' => __('State/County', 'woothemes')
|
|
|
|
)
|
2011-12-16 21:19:56 +00:00
|
|
|
));
|
2011-12-16 15:11:41 +00:00
|
|
|
|
2011-12-15 23:24:02 +00:00
|
|
|
endif;
|
|
|
|
|
2011-12-16 15:11:41 +00:00
|
|
|
return $this->locale;
|
2011-12-15 23:24:02 +00:00
|
|
|
|
|
|
|
}
|
2011-12-16 15:11:41 +00:00
|
|
|
|
|
|
|
/** Apply locale and get address fields */
|
|
|
|
function get_address_fields( $country, $type = 'billing_' ) {
|
|
|
|
global $woocommerce;
|
|
|
|
|
|
|
|
$locale = $this->get_country_locale();
|
|
|
|
|
|
|
|
$fields = array(
|
|
|
|
'first_name' => array(
|
|
|
|
'label' => __('First Name', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-first'),
|
|
|
|
),
|
|
|
|
'last_name' => array(
|
|
|
|
'label' => __('Last Name', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-last'),
|
|
|
|
'clear' => true
|
|
|
|
),
|
|
|
|
'company' => array(
|
|
|
|
'label' => __('Company Name', 'woothemes'),
|
|
|
|
'placeholder' => __('Company (optional)', 'woothemes'),
|
|
|
|
'clear' => true
|
|
|
|
),
|
|
|
|
'address_1' => array(
|
|
|
|
'label' => __('Address', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-first'),
|
|
|
|
),
|
|
|
|
'address_2' => array(
|
|
|
|
'label' => __('Address 2', 'woothemes'),
|
|
|
|
'placeholder' => __('Address 2 (optional)', 'woothemes'),
|
|
|
|
'class' => array('form-row-last'),
|
|
|
|
'label_class' => array('hidden'),
|
|
|
|
'clear' => true
|
|
|
|
),
|
|
|
|
'city' => array(
|
|
|
|
'label' => __('Town/City', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-first'),
|
|
|
|
),
|
|
|
|
'postcode' => array(
|
|
|
|
'label' => __('Postcode/Zip', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-last', 'update_totals_on_change'),
|
|
|
|
'clear' => true
|
|
|
|
),
|
|
|
|
'country' => array(
|
|
|
|
'type' => 'country',
|
|
|
|
'label' => __('Country', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-first', 'update_totals_on_change', 'country_select'),
|
|
|
|
),
|
|
|
|
'state' => array(
|
|
|
|
'type' => 'state',
|
|
|
|
'label' => __('State/County', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-last', 'update_totals_on_change'),
|
|
|
|
'clear' => true
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isset($locale[$country])) :
|
|
|
|
|
|
|
|
$fields = woocommerce_array_overlay( $fields, $locale[$country] );
|
|
|
|
|
|
|
|
if (isset($locale[$country]['postcode_before_city'])) :
|
|
|
|
$fields['city']['class'] = array('form-row-last');
|
|
|
|
$fields['postcode']['class'] = array('form-row-first', 'update_totals_on_change');
|
|
|
|
endif;
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
|
|
|
// Prepend field keys
|
|
|
|
$address_fields = array();
|
|
|
|
|
|
|
|
foreach ($fields as $key => $value) :
|
|
|
|
$address_fields[$type . $key] = $value;
|
|
|
|
endforeach;
|
|
|
|
|
|
|
|
// Billing/Shipping Specific
|
|
|
|
if ($type=='billing_') :
|
2011-08-09 15:16:18 +00:00
|
|
|
|
2011-12-16 15:11:41 +00:00
|
|
|
$address_fields['billing_email'] = array(
|
|
|
|
'label' => __('Email Address', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-first')
|
|
|
|
);
|
|
|
|
$address_fields['billing_phone'] = array(
|
|
|
|
'label' => __('Phone', 'woothemes'),
|
|
|
|
'required' => true,
|
|
|
|
'class' => array('form-row-last'),
|
|
|
|
'clear' => true
|
|
|
|
);
|
|
|
|
|
|
|
|
$address_fields = apply_filters('woocommerce_billing_fields', $address_fields);
|
|
|
|
else :
|
|
|
|
$address_fields = apply_filters('woocommerce_shipping_fields', $address_fields);
|
|
|
|
endif;
|
|
|
|
|
|
|
|
// Return
|
|
|
|
return $address_fields;
|
|
|
|
}
|
|
|
|
}
|