Add New Country to WooCommerce Countries List

  • iftekhar
  • Oct 10, 2015
  • 0 comment
  • 3035 Views
  • Print

By default, WooCommerce has a list of countries that can be used for storing customer’s shipping and billing information. The list includes most of the country in the World. However, just in case if you can’t find your country on that list, you can easily add your country on the list. Here is the snippet.

/* Add a country to countries list - PHP */
function add_country_to_the_list($country) {
   $country["AE-DU"] = 'Dubai';  
   return $country; }
add_filter('woocommerce_countries','add_country_to_the_list', 10, 1);

All you gotta do now is to copy and paste the snippet mentioned above on your theme’s functions.php page and update it. Now go back to your profile page and check out for the name you just added.

Using this snippet, you can add pretty much as many country as you want.

References: add_filter, woocommerce_countries

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.