Discussions

Billing Address always has State field?

I was under the impression the address fields were totally automatic, but when I load my check out screen the address has country of UK but also includes a mandatory State field?

This shouldn't exist on British address?

Posted: Aug 31, 2011

Comments

purplemonkey on September 2, 2011

looks like the "address.inc" file contains a switch to force Great Britian address to include the State field. not sure why? but anyway line 82 of said file, remove the 'GB' entry and all is well.

edited extract
// Those countries generally use their administrative division in postal addresses.
if (in_array($address['country'], array('AR', 'AU', 'BR', 'BS', 'BY', 'BZ', 'CA', 'CN', 'DO', 'EG', 'ES', 'FJ', 'FM', 'HN', 'ID', 'IE', 'IN', 'IT', 'JO', 'JP', 'KI', 'KN', 'KR', 'KW', 'KY', 'KZ', 'MX', 'MY', 'MZ', 'NG', 'NI', 'NR', 'NZ', 'OM', 'PA', 'PF', 'PG', 'PH', 'PR', 'PW', 'RU', 'SM', 'SO', 'SR', 'SV', 'TH', 'TW', 'UA', 'US', 'UY', 'VE', 'VI', 'VN', 'YU', 'ZA'))) {
$format['locality_block']['administrative_area'] = array(
'#title' => t('State'),
'#size' => 10,
'#required' => TRUE,
'#prefix' => ' ',
'#attributes' => array('class' => array('state')),
);
}

Amarjit on February 2, 2012

This would remove state from the form.

You could rename state to county by adding the snippet below.
Please note that the first 4 lines should be added above the last line (the comment).

// Those countries generally use the term county instead of state
if (in_array($address['country'], array('GB'))) {
  $format['locality_block']['administrative_area']['#title'] = t('County');
}
 
// A few contries have a well-known list of administrative divisions.