Skip to content

Instantly share code, notes, and snippets.

@jorpdesigns
Last active July 15, 2021 12:17
Show Gist options
  • Save jorpdesigns/9beadf5238eb76374ecd4f8cf448a8f8 to your computer and use it in GitHub Desktop.
Save jorpdesigns/9beadf5238eb76374ecd4f8cf448a8f8 to your computer and use it in GitHub Desktop.
Snippet to add Northern Ireland to WooCommerce countries list
<?php
// ADD NEW COUNTRY
add_filter( 'woocommerce_countries', 'custom_country_nothern_ireland' );
function custom_country_nothern_ireland( $countries ) {
$new_countries = array( 'NIRE' => __( 'Northern Ireland', 'woocommerce' ), );
return array_merge( $countries, $new_countries );
}
// ADD NEW COUNTRY UNDER CONTINENT
add_filter( 'woocommerce_continents', 'add_nothern_ireland_to_continents' );
function add_nothern_ireland_to_continents( $continents ) {
$continents['EU']['countries'][] = 'NIRE';
return $continents;
}
// RENEAME UNITED KINGDOM
add_filter( 'woocommerce_countries', 'rename_uk' );
function rename_uk( $countries ) {
$countries['GB'] = 'United Kingdom (excl. Northern Ireland)';
return $countries;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment