Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active April 9, 2019 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save woogists/963d2f74a54d84a912f485b21ed4435f to your computer and use it in GitHub Desktop.
Save woogists/963d2f74a54d84a912f485b21ed4435f to your computer and use it in GitHub Desktop.
Add a new country to countries list
/**
* 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;
}
@tara2
Copy link

tara2 commented Apr 9, 2019

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 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment