Magento Expert Forum - Improve your Magento experience

Results 1 to 6 of 6

How to Display visitors country name with the Flag magento

  1. #1
    New member
    Join Date
    May 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to Display visitors country name with the Flag magento

    Hi guys, I am trying to display the visitors country name with the flag in magento header. But i am couldn't able to display it.
    I checked in forums,they have given the solution is get the visitors ip using server http forward for code and sent the ip address to some other third party website to fetch the country. But they have pointed out that using http method is not a safer one. Is there any solution in magento to get ipaddress, country name and flag of the visitors in magento. Please advice me

    View more threads in the same category:


  2. #2
    Junior Member knowband.plugins's Avatar
    Join Date
    Jul 2016
    Location
    Noida, India
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Bale View Post
    Hi guys, I am trying to display the visitors country name with the flag in magento header. But i am couldn't able to display it.
    I checked in forums,they have given the solution is get the visitors ip using server http forward for code and sent the ip address to some other third party website to fetch the country. But they have pointed out that using http method is not a safer one. Is there any solution in magento to get ipaddress, country name and flag of the visitors in magento. Please advice me

    Hello!

    For displaying of the user’s country, you definitely need the third party extension.

    As to get the country name by IP you need to connect geoip library and it gives you such opportunity.

  3. #3
    Junior Member
    Join Date
    Jan 2016
    Location
    Rajkot, Gujarat, India
    Posts
    20
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Hi,

    You need to edit your page.XML file

    Here are the path are

    app>design>frontend/default>Name of your theme>layout>page.xml

    Then you need to go around 58th line

    Please note that you need to put your country flag image folder under "skin>frontend>default>YOURTHEME>images>flag>your_ flag_FLAGNAME.jpg

    Here you need to use one third party addons called firebug to find out the image name and then you need to place that image on particular folder.

    Hope this will work best for you.

    Thank you.

  4. #4
    Junior Member Magento Nguyen's Avatar
    Join Date
    Jun 2015
    Posts
    958
    Thanks
    0
    Thanked 13 Times in 13 Posts

    Default

    Check this link:
    http://magento.stackexchange.com/que...ed-on-location

    It might help you.

  5. #5
    Junior Member knowband.plugins's Avatar
    Join Date
    Jul 2016
    Location
    Noida, India
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    To find the country of user you have to use the service of geoip2. It has an extensive databases covering 99.9999% of IP addresses in use. They keep updating there database regularly. Using it you an find country of the user. Now you will need flags of all the countries. You can download it from here http://flagpedia.net/download. After finding country of a visitor you can customize the view or redirect it to desired store.

    Check our Magento Extensions at Knowband.com

  6. #6
    Junior Member
    Join Date
    Aug 2016
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    There is a magento GeoIP extension which downloads latest maxmind data file and periodically updates it. I suggest hooking into controlller_front_init_before event. You can use the following code to check get the ISO 3166-1 code of visitors country and then redirect him to corespondent store view if you have one.

    $geoIP = Mage::getSingleton('geoip/country');
    $code = $geoIP->getCountry();

    /*
    * Check if store view for this country/language exists and it is not a current store view.
    * If so do a redirect.
    * You can also take a language from user agent into consideration.
    */

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •