Skip to content

Instantly share code, notes, and snippets.

@stuartduff
Last active February 18, 2021 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartduff/1c7155ed479602c1c76c7c2fbaab8814 to your computer and use it in GitHub Desktop.
Save stuartduff/1c7155ed479602c1c76c7c2fbaab8814 to your computer and use it in GitHub Desktop.
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