RSS Feed
^__^

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 responses to “Check if a country is an EU country in Magento”

  1. Mayorga says:

    Very useful, thanks!

  2. Freek says:

    Hello,

    Just so you know you could also just use this:

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

    Brilliant, thanks!

  4. Vinod Kumar says:

    Hi,

    How can I get European countries list in magento 2

Leave a Reply

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