Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Changes the county field to state/region to separate regions in the UK for brexit.
/**
* Changes the county field to state/region to separate regions in the UK for brexit.
* This can be used to specify specific shipping zones for UK regions, like exluding Northern Ireland from UK shipping.
*/
function custom_woocommerce_uk_states_brexit( $states ) {
$states['GB'] = array(
'ENG' => 'England',
'SCO' => 'Scotland',
'WAL' => 'Wales',
'NIRE' => 'Northern Ireland'
);
return $states;
}
add_filter( 'woocommerce_states', 'custom_woocommerce_uk_states_brexit' );
function wc_change_uk_locale_field_defaults_brexit($countries) {
$countries['GB']['country']['required'] = true;
$countries['GB']['country']['label'] = 'Country';
$countries['GB']['state']['required'] = true;
$countries['GB']['state']['label'] = 'Region';
return $countries;
}
add_filter( 'woocommerce_get_country_locale', 'wc_change_uk_locale_field_defaults_brexit');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment