I did this once for a client. Here is what I did.
Preliminary: GeoIp library for PHP.
1- Create repository views regarding languages ββin your Magento administrator.
2- Add a filtration system by doing:
2a - edit the page.xml layout file of the main / parent theme and around line 35/36 (add in the handle:
<block type="page/html" name="country-filter" output="toHtml" template="page/html/country-filter.phtml" />
2b - Create the template / page / html / country -filter.phtml in the main / parent theme and put this code, which can be changed depending on your needs:
if(!isset($_COOKIE['frontend'])) { setcookie("frontend",session_id(),time()+60*60*24,"/",""); $ip = $_SERVER['REMOTE_ADDR']; $country = geoip_country_name_by_name($ip); switch($country) { case 'France': $url = $this->getUrl() . '?___store=YOUR_STORE_VIEW_CODE_FOR_FRANCE'; header( 'Location:' . $url) ; break;
source share