• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
SnippetPress

SnippetPress

The Home of WordPress Snippets

Vultr Web Hosting
  • Cheat Sheets
  • Reviews
  • Snippets
  • Tutorials

Add Kosovo to List of WooCommerce Countries

May 29, 2020 by SnippetPress Leave a Comment

You may have noticed that Kosovo doesn’t appear in the list of countries on WooCommerce. This is because they haven’t officially been granted an ISO 3166-1 country code. When they do, WooCommerce says they’ll add Kosovo to the list. In the meantime, if you’re selling to Kosovo, here’s how to add it to the list of countries yourself:

add_filter( 'woocommerce_countries',  'snippetpress_add_kosovo' );

function snippetpress_add_kosovo( $countries ) {
	$new_countries = array(
		'XK'  => __( 'Kosovo', 'woocommerce' ),
	);
	return array_merge( $countries, $new_countries );
}

add_filter( 'woocommerce_continents', 'snippetpress_add_kosovo_to_continents' );

function snippetpress_add_kosovo_to_continents( $continents ) {
	$continents['EU']['countries'][] = 'XK';
	return $continents;
}

In the code above, we use the country code XK, as this is the temporary country code that is used for Kosovo. The code will add Kosovo to the list of WooCommerce countries and also add it to the list of countries in Europe.

Where to add the snippet?

The snippet should be placed at the bottom of the functions.php file of your child theme. Make sure you know what you’re doing when editing this file. Alternatively, you can use a plugin such as Code Snippets to add the custom code to your WordPress site. If you need further guidance on how to add the code, check out our post on How to Add WordPress Snippets.

Filed Under: Snippets, Snippets, WooCommerce

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

E-mail Newsletter

More to See

WooCommerce – Prevent Product Being Added To Cart If A Specific Product Is Already In Cart

July 15, 2020 By SnippetPress

WooCommerce – Display an “Add $X To Get Free Shipping” Notice

July 13, 2020 By SnippetPress

Footer

Recent

  • Change The WordPress Page Title Separator Without A Plugin
  • WooCommerce – Prevent Product Being Added To Cart If A Specific Product Is Already In Cart
  • WooCommerce – Display an “Add $X To Get Free Shipping” Notice
  • WooCommerce – Integrate Google Merchant Center Customer Reviews
  • WooCommerce – Disable Out of Stock Variations

Search

Copyright © 2023 ·SnippetPress