Check if a country is an EU country in Magento

I you ever wondered how you can check if a Country, resp. a Country Code, is in the EU, i did the following:

Magento has a config value: eu_countries that lists all Countries of the EU.

You can find it in the backend under:
Configuration -> General -> Country Options.

Against this list you can validate your country code, f.e. that you got in an billing or shipping address of an order.

$address = $order->getBillingAddress()->getData();
$eu_countries = Mage::getStoreConfig('general/country/eu_countries');
$eu_countries_array = explode(',',$eu_countries);
if(in_array($address['country_id'], $eu_countries_array)){
//do something useful:
//for example show a tax hint like this german one: 'steuerfreie innergemeinschaftliche Lieferung'
}

Pretty simple, once you know!

Do you know any other way?

Let me know!

5 Replies to “Check if a country is an EU country in Magento”

  1. Hello,

    Just so you know you could also just use this:

    if(Mage::helper('core')->isCountryInEU($order->getBillingAddress()->getCountryId()))
    {
    
    }
    

Comments are closed.