Add a new country to countries list
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
/** | |
* Add a new country to countries list | |
*/ | |
add_filter( 'woocommerce_countries', 'handsome_bearded_guy_add_my_country' ); | |
function handsome_bearded_guy_add_my_country( $countries ) { | |
$new_countries = array( | |
'NIRE' => __( 'Northern Ireland', 'woocommerce' ), | |
); | |
return array_merge( $countries, $new_countries ); | |
} | |
add_filter( 'woocommerce_continents', 'handsome_bearded_guy_add_my_country_to_continents' ); | |
function handsome_bearded_guy_add_my_country_to_continents( $continents ) { | |
$continents['EU']['countries'][] = 'NIRE'; | |
return $continents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding this here to help anyone else - I couldn't get the code right for adding 'Canary Islands' to shipping zones. Excellent support worker in woo livechat gave me this code and it worked a dream :) It goes in your child theme's functions.php
Add this code first and then go to shipping zones and add the Canary Islands there and it will get added.
/** START: ADDING CANARY ISLANDS TO SHIPPING
Add a new country to countries list
*/
add_filter( 'woocommerce_countries', 'handsome_bearded_guy_add_my_country' );
function handsome_bearded_guy_add_my_country( $countries ) {
$new_countries = array(
'CANISL' => __( 'Canary Islands', 'woocommerce' ),
);
return array_merge( $countries, $new_countries );
}
add_filter( 'woocommerce_continents', 'handsome_bearded_guy_add_my_country_to_continents' );
function handsome_bearded_guy_add_my_country_to_continents( $continents ) {
$continents['EU']['countries'][] = 'CANISL';
return $continents;
}
/*END: ADDING CANARY ISLANDS TO SHIPPING */