Have you ever wanted to change how country names appear in your WooCommerce store? WooCommerce uses standard country names that are widely accepted. However, there are times when you might prefer to change these names to suit your specific needs better. Whether you’re aiming for a more concise version of a country’s name or opting for a term that resonates better with your local audience, WooCommerce allows you to make these adjustments with ease to Rename Country Codes in WooCommerce.
Making these changes is simple and doesn’t require extensive technical knowledge. All it takes is a small snippet of code added to your theme’s functions.php file. You’ll need to make a few adjustments to this code to target the countries you wish to rename.
This straightforward method lets you customize the country names displayed in your store, ensuring they align with your business goals and customer expectations. In this article, we’ll walk you through the process step by step and also introduce some plugins that can provide even more flexibility for those who want advanced options.
For a powerful solution to manage currencies, taxes, and country-based pricing, check out Aelia, a leading provider of WooCommerce plugins designed to enhance your store’s functionality. After you change your country code, you can manage pricing, tax settings, and currency options with greater control, ensuring a seamless shopping experience for your customers.
Step-By-Step Guide to Renaming Country Codes In WooCommerce
Understanding Country Codes in WooCommerce
Country codes are essential in WooCommerce for ensuring the correct handling of shipping, billing, and customer information. These codes follow the ISO 3166-1 alpha-2 standard, which assigns a unique two-letter code to each country (e.g., “US” for the United States and “CA” for Canada).
When a customer enters their address, WooCommerce uses these country codes to identify the appropriate country and apply the correct shipping rates, tax calculations, and regional content. This ensures that the customer’s experience is accurate and tailored to their location.
For a comprehensive list of ISO country codes, you can refer to a trusted online resource on ISO 3166 country codes.
Before we get started, it’s important to understand that modifying the functions.php file can directly affect your theme’s functionality. Be sure to back up your site before proceeding to avoid any accidental changes that could impact your store. The functions.php file is a powerful tool that allows you to add custom code to your site, so it’s crucial to handle it carefully. Once you’re ready, follow the steps below to easily access and modify this file.
Step 1: Open the functions.php File
The first step is to locate and open the functions.php file of your active theme. This is where you’ll add the code snippet to rename country codes in WooCommerce.
Log into your WordPress Dashboard:-

After logging into your WordPress admin, go to the sidebar and click on Appearance > Theme Editor. This will bring up the theme files for your active WordPress theme.
Locate the functions.php file. :-

On the right-hand side of the Theme Editor window, you’ll see a list of template files under Theme Files. Scroll through this list and locate functions.php, which is typically labeled as Theme Functions.
Open the functions.php file:-

Click on functions.php to open it in the Theme Editor. This file contains the custom functions for your WordPress theme, where you will add the code snippet.
Step 2: Add the Code Snippet
Now that you’ve opened the functions.php file, it’s time to add the code that will rename a country code in WooCommerce. Follow these steps:
Copy the Code Snippet Below:
/** * Rename a country */ add_filter( 'woocommerce_countries', 'rename_ireland' ); function rename_ireland( $countries ) { $countries['IE'] = 'Ireland'; // Change 'Ireland' to the name you want return $countries; }
Paste the Code:

Scroll down to the bottom of the functions.php file and paste the above code snippet just before the closing PHP tag (if there is one). This ensures that the snippet is added at the end of the file.
Step 3: Explanation of the Code
If you’re not familiar with PHP or WordPress, the code may look a bit complex at first. However, let’s break it down step by step so you can understand how it works.
PHP Comments :-
The first lines are comments. These are not executed but simply provide information to the person reading the code. In this case, they explain that this block of code is used to rename a country.
Binding a Custom Function to the WooCommerce Filter :
The line uses the add_filter() function to bind a new custom function, rename_ireland(), to the woocommerce_countries filter hook. This hook is responsible for altering country data in WooCommerce.
Renaming the Country :
In the custom function rename_ireland(), the country code IE (which represents Ireland in ISO 3166-1) is renamed. The countries[‘IE’] = ‘Ireland’; line is where the country name is modified. You can change the country code and name to anything you’d like, such as renaming the United States or another country in your store.
Step 4: Customizing the Code for Other Countries
To rename a country other than Ireland, you’ll need to make a few small changes to the code:
- Change the Country Code: The country code is a two-letter abbreviation used by WooCommerce to identify the country. For example, the country code for the United States is US, for Canada, it’s CA, and for the UK, it’s GB. You can replace ‘IE’ with the code of any other country you want to rename.
- Rename the Country: The name after the equal sign is what will display on your website. For instance, if you’re renaming “United States” to “USA,” you would change this line to:
$countries['US'] = 'USA';
- Custom Function Name:
It’s always a good idea to give the custom function a name that helps you remember its purpose. For example, if you’re renaming the United States, you could name the function rename_us or rename_united_states.
Here’s how the code would look for renaming the United States:
php
CopyEdit
/** * Rename a country */ add_filter( 'woocommerce_countries', 'rename_us' ); function rename_us( $countries ) { $countries['US'] = 'USA'; // Renaming US to USA return $countries; }
Be sure to change the function name in both the add_filter line and the function definition, or it won’t work correctly.
Step 5: Save and Close the functions.php File
Once you’ve added the code snippet and made any necessary modifications, it’s time to save your changes:
- Save the File: After you’ve added the code, scroll down and click the Update File button to save your changes.
- Close the File: After saving the file, you can exit the Theme Editor. Your changes will be live on your website!
Step 6: Verify the Changes
Once the changes are saved, it’s important to verify that the country name has been updated correctly on your WooCommerce store:
- Visit the Checkout Page:
Go to your store’s checkout page and see if the country name has changed in the country selection dropdown. - Test the Functionality:
Add a product to the cart and proceed to the checkout process. Ensure that the renamed country appears in the list and that it is functioning as expected (i.e., shipping rates and taxes should still apply correctly).
If you need More Help in WordPress, Consider working with expert WordPress website design and development, working with professionals who specialize in WooCommerce customization. You can explore Marketing The Change for digital marketing solutions to grow your online store efficiently.
Common Issues and Troubleshooting
While renaming country codes in WooCommerce is usually a straightforward process, you might encounter a few common issues:
- Incorrect Country Name Displayed:
Double-check the code you added to ensure you’ve correctly replaced the country code and name. Also, ensure that no other conflicting plugins are overriding these settings. - Code Not Working:
Ensure the code is placed at the very bottom of the functions.php file, just before the closing ?> tag (if it exists). If there’s a syntax error, it may cause the code to malfunction, so check for any missing semicolons or incorrect characters. - Undoing Changes:
If you encounter any issues after making the changes, you can easily undo them by simply removing the code snippet from the functions.php file.
Renaming country codes in WooCommerce is straightforward, but customizing your store for different regions can be much more complex.
If you need to adjust product prices by location, restrict access to certain products in specific countries, or implement other advanced location-based customizations, consider using Aelia’s Prices by Country for WooCommerce plugin.
This versatile tool allows you to fine-tune product pricing and visibility based on customer location.