Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.