Add Kosovo to List of WooCommerce Countries

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?

Whichever snippet you choose to use, you should place it 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.