Last active
February 18, 2021 18:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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