Resources
↑ Back to topThis use-case will focus on the recent changes (as at January 2021) related to Brexit, specifically in terms of configuring different shipping zones in WooCommerce for Nothern Ireland. These shipping zones will focus on Nothern Ireland’s counties, rather than using wildcard shipping zones.
For more in-depth information on how Brexit affects WooCommerce stores, please review the following guides first:
- The WooCommerce Store Owners Guide
- The Developers guide to Changes in the Core WooCommerce Code
Scenario
↑ Back to topJohn, a shop owner based in London sells custom motorbikes to the Republic of Ireland. Due to the recent changes in duties & tarrifs in Brexit, John needs to configure a separate shipping zone for Northern Ireland due to the following reasons:
- Not all of his regular shipping providers currently cover Northern Ireland;
- The costs associated with shipping to Northern Ireland are significantly different that the rest of the United Kingdom
Requirements
↑ Back to topFor this use-case, the following extensions are needed:
- Shipping Locations Pro – Used for adding the states/locations for the whole of the United Kingdom, including Northern Ireland.
Configuration
↑ Back to topCreating a New Shipping Zone for Northern Ireland
↑ Back to top- Log in to the WordPress admin area
- Ensure that Shipping Locations Pro is installed & active
- Navigate to WooCommerce > Settings > Shipping
- Select Add Shipping Zone
- In the Zone name field, enter “Northern Ireland”
- In the Zone regions field, select Europe > United Kingdom. Scroll down the list of counties and select the following:
- Co. Antrim, United Kingdom (UK)
- Co. Armagh, United Kingdom (UK)
- Co. Down, United Kingdom (UK)
- Co. Londonderry, United Kingdom (UK)
- Co. Fermanagh, United Kingdom (UK)
- Co. Tyrone, United Kingdom (UK)
- Select Save changes
Adding a New Shipping Method for Northern Ireland
↑ Back to top- Using the same shipping zone that was just created, select Add shipping method
- In the lightbox popup area, select Flat rate
- Once added, hover over the new shipping method and select Edit
- Change the Method title to Regular Shipping
- Add a Cost of £5
- Repeat steps #1 – #5, adding as many applicable shipping methods for Northern Ireland as you see fit.
The shipping methods listed above are for illustrative purposes only. For actual shipping rates based on the number, size and weight of the products in the cart, please use a shipping rate calculator extension like Royal Mail.
Result
↑ Back to topWhen configured correctly, the results are illustrated below:
Regular Shipping
Add Northern Ireland as Standalone Country
↑ Back to topWhile it’s not something we recommend as Northern Ireland is part of the United Kingdom, certain shop owners might prefer to display Northern Ireland as its own standalone country. To do that, please follow these steps:
- Install a plugin that allows shop owner to add code snippet (e.g. Code Snippets)
- In the Code Snippets settings, add the following custom code:
/**
* Add Northern Ireland to the list of countries in WooCommerce.
*
* @param array $countries Existing list of countries.
* @return array Modified list of countries.
*/
function add_northern_ireland_country($countries) {
$new_countries = array(
'NIR' => __( 'Northern Ireland', 'woocommerce' ),
);
return array_merge($countries, $new_countries);
}
add_filter('woocommerce_countries', 'add_northern_ireland_country');
/**
* Add Northern Ireland to the list of allowed countries for shipping.
*
* @param array $postcodes Existing list of postcodes.
* @param int $instance_id Shipping zone instance ID.
* @param int $zone_id Shipping zone ID.
* @return array Modified list of postcodes.
*/
function add_northern_ireland_shipping_zone($postcodes, $instance_id, $zone_id) {
if (!is_array($postcodes)) {
$postcodes = array();
}
$postcodes[] = 'NIR';
return $postcodes;
}
add_filter('woocommerce_shipping_zone_postcodes', 'add_northern_ireland_shipping_zone', 10, 3);
/**
* Ensure Northern Ireland is available in the billing and shipping country dropdowns.
*
* @param array $locales Existing list of country locales.
* @return array Modified list of country locales.
*/
function add_northern_ireland_country_locale($locales) {
$locales['NIR'] = array(
'postcode' => array(
'required' => false,
'hidden' => false,
),
'state' => array(
'required' => false,
'hidden' => false,
),
'city' => array(
'required' => true,
'hidden' => false,
),
);
return $locales;
}
add_filter('woocommerce_get_country_locale', 'add_northern_ireland_country_locale');
/**
* Add Northern Ireland to the continents list in WooCommerce.
*
* @param array $continents Existing list of continents and countries.
* @return array Modified list of continents and countries.
*/
function add_northern_ireland_to_continents_list($continents) {
$continents['EU']['countries'][] = 'NIR';
return $continents;
}
add_filter('woocommerce_continents', 'add_northern_ireland_to_continents_list');
3. Navigate to the Shipping Locations settings located under WooCommerce > Locations
4. Locate “Northern Ireland” and add the respective counties
Please note: If your store allows customers to select between both Northern Ireland and the United Kingdom during checkout, we recommend removing the Northern ireland counties from the United Kingdom. This is possible by selecting “United Kingdom” in step #4 above and hovering over each matching county to delete.