Rename Country Codes in WooCommerce2

How to Easily Rename Country Codes in WooCommerce

Have you ever wanted to change how country names appear in your WooCommerce store? Maybe you need a shorter country code or a different language for customer clarity. Fortunately, WooCommerce makes customizing country codes a straightforward process.

 

Explore our full range of WooCommerce plugins here

 

Step-By-Step Guide to Renaming Country Codes In WooCommerce

 

Understanding Country Codes

 

Country codes are essential for ensuring accurate shipping, billing, and overall customer experience in WooCommerce. They follow the ISO 3166-1 alpha-2 standard, which means each country has a unique two-letter code (e.g., “US” for the United States, “CA” for Canada).

 

Whenever a customer enters their address, WooCommerce uses these codes to match the appropriate country. This helps determine shipping rates, taxes, and even display region-specific information.

 

Locating the functions.php File:

 

Your theme’s functions.php file is where you can add small snippets of code to modify how WooCommerce works. Let’s find it:

Method 1: Via Your WordPress Dashboard

 

  1. Log in to your WordPress Dashboard.
  2. On the left-sidebar, go to Appearance -> Theme Editor.
  3. On the right, you’ll see a list of theme files. Look for functions.php (Theme Functions). Click on it to open.

Rename Country Codes in WooCommerce

 

Method 2: Via an FTP/File Manager

 

  1. Access your website’s files using an FTP client (like FileZilla) or your hosting provider’s file manager.
  2. Navigate to your theme’s root folder (often inside /wp-content/themes/your-theme-name/).
  3. Find and open the functions.php file.

 

Rename Country Codes in WooCommerce2

 

IMPORTANT: Child Themes

Before making any changes, it’s strongly recommended to use a child theme. This prevents your customizations from being lost when you update your main theme.

Adding the Code Snippet

 

Let’s do the rename! Copy and paste the following code at the bottom of your functions.php file:

 

Plain text version of the above:

 

PHP


function rename_country_code( $countries ) {
// Rename "US" (United States) to "USA"
$countries['US'] = 'USA';


// Add more renaming cases if needed:
// $countries['XX'] = 'YY'; // Where 'XX' is the old code, 'YY' is the new code


return $countries;
}
add_filter( 'woocommerce_countries', 'rename_country_code' );

Understanding the code:

 

  • The first line connects a new function (which we’ll define below) to WooCommerce’s list of countries.
  • my_country_rename is the name of our function. Feel free to change it to something that describes your specific change.
  • Inside the function, we change the ‘US’ country code to ‘United States’. This part is where you’ll make your edits.

 

Customizing for Your Needs

 

Make it your own:

  1. Replace ‘US’ with the two-letter code of the country you want to rename.
  2. Replace ‘United States’ with the new name you’d like to display on your store.

 

WooCommerce Country Code Rename FAQs

 

What is a country code?
Country codes are standardized two-letter abbreviations that represent countries and territories around the world (e.g., “GB” for Great Britain, “DE” for Germany). These codes, defined within the ISO 3166-1 alpha-2 standard, are a crucial part of online stores, ensuring they can process customer addresses accurately for shipping and billing.

 

How do I change the default country code in WooCommerce?
In WooCommerce, you can’t technically change the overall default country for your entire store. However, you have the flexibility to rename specific countries as needed. This lets you customize how they appear to your customers during checkout and within their account information.

 

What countries does WooCommerce support?
WooCommerce is designed to support virtually all countries across the globe. You can find a comprehensive list of ISO 3166-1 alpha-2 country codes to check if your required country is included. Keep in mind, the renaming process we’ve outlined works for any country supported by WooCommerce.

 

Additional Considerations – Potential Conflicts

 

While renaming country codes is usually straightforward, it’s good to be aware that custom code changes can sometimes lead to unexpected conflicts, especially in stores with lots of plugins or complex setups. If you run into any issues, it’s sometimes best to consult a WooCommerce developer for help.

 

In Closing

 

While the process of renaming country codes in WooCommerce is relatively simple, tailoring your store to customers in different regions can get far more intricate.

 

If you need to set different product prices based on location, hide certain products from specific countries, or have other complex location-based customizations in mind, consider exploring Aelia’s Prices by Country for WooCommerce plugin.

 

This powerful tool gives you granular control over your product pricing and visibility based on customer location.

 

Want to learn more or need help with advanced WooCommerce customizations? We’d love to hear from you!

Business All-Stars Accreditation Logo 2020-White Background

Aelia Receives All-Star Quality Mark from AIBF for the second year in a row

Our beloved Grinzing, located in one of the most beautiful districts of Vienna, has received a massive boost this week with one of the resident businesses achieving international recognition for excellence, confirming its highest standards of service and trust. Diego Zanella, the founder of Aelia, was awarded the coveted All-Ireland Business All-Star accreditation for the second year in a row. One might ask why an Austrian business, founded by an Italian entrepreneur, would receive such an important accreditation from a foreign country, and it would be a legitimate question. The answer is simple, yet interesting.

Some background story

Diego Zanella founded Aelia in Ireland, in 2013. From the first day, he founder focused all its efforts in producing high quality solutions, and offering top class service, to owner of e-commerce websites. Thanks to the flexibility offered by modern technologies, the business can operate from anywhere in the world, while still keeping in touch with its thousands of customers. Aelia moved around Ireland a couple of times, then, in mid-2019, Diego Zanella planned a relocation to Austria.

The All-Ireland Business Foundation came into play, just in time

At the beginning of the same year, he had submitted Aelia to the selection for the Business All-Star accreditation. He was supposed to receive answer was supposed within a couple of days, and the selection process take a few weeks. However, due to a technical issue, the submission remained “pending” much longer than it should have. As soon as the All-Ireland Business Foundation Team found it, they reviewed the performance of both Aelia and its founder. The score was high enough to place them amongst the top candidates.  Even though our founder informed the AIBF Team of the imminent relocation abroad, they were more than happy to let our application proceed anyway. Then, in October 2019, Diego Zanella received the first Business All-Star accreditation.

In 2020, the AIBF Team contacted our founder again. Although our Aelia and its founder are no longer resident in Ireland, their result were so high that the Foundation offered to make an exception, and participate to the selection again. Diego Zanella was given the opportunity to become the first “ex-indigenous entrepreneur” to be accredited by the All-Ireland Business Foundation.

Obviously, since we’re writing about it, the result was a success. At the end of October 2020 (yes, we’re a bit slow with news), Aelia’s founder received the accreditation certificate, confirming Diego Zanella as a Thought Leader in e-commerce and WooCommerce solutions.

Aelia - Certificate of Accreditation 2020

Aelia – Certificate of Accreditation 2020

Due to the ongoing COVID-19 pandemic, the Gold Medal Ceremony was replaced by an online event. Our founder, Diego Zanella, attended it on the 30th of October, 2020.

The importance of get accredited for the second year

Like in 2019, we are pleased to have reached the high standard required by the the Business All-Star accreditation. We strive to keep high level of performance, trust and customer satisfaction that distinguishes our offer . Furthermore, we are the first to having been invited to participate into the selection, despite the business being now resident in another EU country, and it feels like a special honour. The All-Ireland Business Foundation is so impressed by our results that they would like to keep us in their register of top class companies. 👍

We would like to thank everyone for your continued support. Our customers, who keep trusting, our business partners, with whom we will be working on more incredible projects and, most importantly, our families.

Thanks again for your invaluable help. We wouldn’t be here, if it weren’t for you. 🙏

The Aelia Team

Business All-Star Accredited

We received the Business All-Star Accreditation. That’s awesome!

Over the past few weeks, our founder has been working with the All Ireland Business Foundation to achieve the prestigious Business All-Star Accreditation. The examination panel informed us that our efforts has been successful, and we have reached our goal. The accreditation is a great achievement, and a demonstration that we, at Aelia, offer to our clients high quality products and a top class customer service.

Business All-Star - Accreditation Certificate

Our founder, Diego Zanella, will attend the Gold Medal Ceremony on the 25th of October, 2019, at Croke Park, in Dublin, Ireland.

What this means for Aelia

It’s always great to see efforts recognised and rewarded. It’s also very exciting to know that we reached the standard required by the All-Ireland Business Foundation. The Business All-Star accreditation distinguishes progressive Irish businesses that meet a high level of verified performance, trust and customer centricity. Our efforts will now allow us to join unique group of excelling businesses.

Why we are so excited

The achievement will be celebrated at Croke Park, but reaching certainly wasn’t a “walk in the park“. 😃

We feel that this result is a tangible demonstration to our commitment in offering top quality products and services to our customers, as well as our collaborators.

We would like to thank all of you, customers, supporters, partners and suppliers, for having been with us during the past six years. Your continued support is what allowed us to be successful. We will strive to stay at the top of our class, and keeping offer you the great service you have come to expect from us.

The Aelia Team

WooCommerce Tax Display by Country – Multiple improvements – Updates

WooCommerce Tax Display by Country – What’s new

The Tax Display by Country plugin for WooCommerce has been updated to version 1.9.7.170912. This update brings the following improvements and fixes:

  • Added support for the new “hashed fragments” used by the minicart since WooCommerce 3.1.2. This will ensure that the minicart displays the correct prices when the country changes.
  • Added logic to preserve customer’s city and postcode, if set.
  • Improved logic used to detect customer’s country and province in WooCommerce 3.0 and newer.

How to get latest version

New customers

Simply place your order and you will get the latest version.

Existing customers

You should be able to download the updated file using the link you received with your order. If the link doesn’t work, please contact Support to receive the latest version. Thanks.

EU VAT rate update – Greece – Updates

We have recently been informed that the standard VAT rate for Greece was changed on the 1st June 2016, from 23% to 24%. Some changes were made to reduced VAT rates as well.

We would recommend to take the opportunity to update the VAT rates configured in your system, to make sure that you are using the correct ones.

How to update the tax rates

Updating tax rates is a simple operation:

  1. Go to WordPress Admin > WooCommerce > Settings > Tax.
  2. Click on the tax rate you would like to update (e.g. “Standard“), at the top of the page.
  3. Change the rate in the row with the country code “GR” to “24”.
  4. Save the changes.

If you are using our EU VAT Assistant plugin, you can update all EU tax rates with a single click. Simply select the rate type at the bottom of the page and click on Update EU VAT Rates. Make sure that you select the appropriate rates (Standard or Reduced), the plugin will do the rest.

With our EU VAT Assistant you can update all VAT rates with a single click

Once the operation is completed, review the tax rates, to ensure that they are correct, and click on Save Changes. WooCommerce will now use the new rates.

Quick and easy!

news icon

WooCommerce and cache – Part 2: new Cache Handler plugin

Read Part 1: WooCommerce Currency Switcher and cache – Making them work together

Some months ago, we wrote about one of the most common issues faced by merchants who run highly dynamic websites, which include multi-currency, multi-pricing, geolocation features: stale content served by rigid caching systems.

In brief, there are quite a few caching systems designed with the assumption that the content of a site is the same for anyone. No matter who is opening a page, they serve the same information. This is correct for relatively static sites, such as blogs, which show the same articles to every member of the audience, or simple e-shops, where the prices are set, and are the same for every customer.

In a few words, many caching systems assume that, given a page on a site, the content of such page will always be the same, without exception. As we explained, this is incorrect when a site is highly dynamic. A shop that handles multiple currencies may be showing different prices to different visitors, or it might need to show a different tax rate (this is actually a requirement in many countries), on the exact same page.

With a static caching system, the result is that users may end up seeing the wrong content. This makes for a worse user experience, and can have an impact on conversion.

After an in-depth analysis, and several experiments, we came to a conclusion: issues caused by the caching system must be solved by the caching system. Based on this approach, we prepared an algorithm for dynamic caching that handles the needs of a multi-currency, multi-pricing, multi-language shop as it should, without compromising on the performance. This, in our opinion, is the correct way to address the issue.

The status of Dynamic Caching today

We keep contacting as many hosting providers as possible, explaining them how they should update their caching systems to bring them up to speed. Our objective is to make it clear that handling highly dynamic caching is a must, not just a “frill”.

Quite a few providers agreed with our approach, and allow their customers to customise the caching logic as required. Others, like the WP Engine team, showed interest in our solution, and are currently reviewing it, for future implementation. There are some who are still “lagging behind”, and there are a few, such as CloudFlare, who only offer dynamic caching on their most expensive plans.

Due to these limitations, imposed by an obsolete architecture, merchants have make a difficult decision:

  • Change hosting/service provider and move to one that handles caching as it should. This would make sense, but it’s not always possible. Besides, merchants might have invested a significant sum in current service.
  • Disable the caching system they are using, and for which they might have been paying a service fee.
  • Abandon the idea of a multi-currency, multi-language site, potentially risking to drive away audience.

While we still maintain that caching issues must be addressed on the caching layer, we wanted to find a solution that would help merchants, at least temporarily, while the service providers update their system.

Welcome our new plugin: WooCommerce Cache Handler

Thanks to our customers’ support, we are happy to announce the release of the WooCommerce Cache Handler plugin (currently in Beta stage). This new plugin can be used as a workaround with rigid caching systems, such as CloudFlare, SiteGround “Dynamic” Cache (which is actually static), as well as plugins that don’t support dynamic caching, such as W3 Total Cache.

Please note that our recommendation is still to consider switching to a more flexible solution, but this plugin will cover you until you are ready for that change.

How it works

The WooCommerce Cache Handler is simple to use. All you have to do after installing the plugin is go to WooCommerce Settings > Cache Handler and choose the handler you prefer.

WooCommerce Cache Handler - Configuration page

Configuring WooCommerce Cache Handler is extremely easy. Simply choose your favourite handler, clear the cache, and you are ready to go!

After that simple selection, the Cache Handler will support our Currency Switcher, Prices by Country, Tax Display by Country, and all our other WooCommerce plugins.

Currently, there are three options available.

1. Disabled

As the name implies, this disable all the features of the plugin. It can be useful for testing.

2. Redirect

This option is an almost exact equivalent of the “caching support” feature implemented by WooCommerce, which is enabled when the Default Customer Address is set to Geolocate (with page caching support).

The major difference from the standard feature is that our handler takes into account details such as the currency, customer’s country, customer’s state, customer’s tax exemption, and so on, ensuring that the correct content is served to customers based on these parameters. Like the original workaround from which it was derived, this handler appends a random string to URLs.

Benefits and drawbacks

+ The Redirect handler is based on the original workaround implemented by WooCommerce.
+ This solution works on a page level, thus it can produce the correct content with any configuration, or 3rd party plugins.
– The URLs look “ugly”, due to the string appended to them to work around the limitations of caching.

3. Ajax Loader

The Ajax Loader is an alternative to the Redirect, and it’s more elegant, as it doesn’t alter page URLs with ugly, random text. This handler loads all pricing elements via Ajax, when the page load is completed. The result is the following:

  1. A visitor connects to your site from the US. He would like to see USD.
  2. The rigid caching system has the page cached in EUR, and serves it to the customer.
  3. The Ajax Loader kicks in as soon as the page is loaded, requesting the updated prices from the server. After a brief moment, all elements that were displayed in EUR are changed to USD, as the visitor would expect.This update is very quick, and, at the moment, it processes the following standard elements :
    – Product prices
    – Currency selectors
    – Price filter widget
    – Custom prices displayed with the Currency Switcher shortcodes.

Benefits and drawbacks

+ The Ajax Loader is a more elegant solution than reloading the page after appending a random string to the URL.
+ Page load is faster, as there is no redirect.
+ URLs are not altered. There is no random text appended to them.
– The Ajax Loader can only process standard elements on the page. If 3rd party plugins add their own pricing elements, such addon prices, custom totals, etc, those won’t be updated. It will be up to the 3rd party plugins’ authors to “hook” into the Ajax Loader and refresh their elements via Ajax.

How to get the WooCommerce Cache Handler

The WooCommerce Cache Handler is available free of charge. Please feel free to download and try it, and see how it works for you. Whether you are using CloudFlare, SiteGround, WP Engine, Flywheel, or any other service with static caching, the Cache Handler got you covered!

Questions? Feedback?

The Cache Handler is still in Beta stage and that, as any free plugin, it’s not covered our free support. We would recommend to try it on a staging copy of your site, so that the live site won’t not affected by bugs that we eventually have to address.

We also would like to encourage you to share your feedback by contacting us. If you wish to contribute to the development of this plugin, you are more than welcome to do so!

Thanks for reading, and see you soon on aelia.co!

The Aelia Team