cancel
Showing results for 
Search instead for 
Did you mean: 

How to Display visitors country name with the Flag

How to Display visitors country name with the Flag

Hi Guys,

 

I am new to magento, I am trying to display our visitors country name with the flag in the header position

But cant able to do is as most of the api sites were providing ipaddress using http forward request in php which i found in google

which is not the safe way of doing it. Is there anyway we can able to use mage code for getting ipaddress and country names of the visiors, Please advice me guys

2 REPLIES

Re: How to Display visitors country name with the Flag

Check this link:

http://magento.stackexchange.com/questions/4/displaying-appropriate-localisation-based-on-location

 

It might help you.

 

OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions

Re: How to Display visitors country name with the Flag

Hi, 

 

The code for getting IP address is implemented here

\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress on getRemoteAddress() method.

After getting the IP address using this, you can make a curl call to http://freegeoip.net/ website as JSON format. you will get the country name. 

And for adding flags, you can use class names for the HTML tag to show each flag based on each country. More info on making a call is described here