11/21/2012

magento:IP SPECIFIC LANGUAGE

 First download currency switcher from   
http://www.magentocommerce.com/magento-connect/auto-currency-switcher-8671.html
//CODE TO DISPLAY LANGUAGE ACCORDING TO IP ADDRESS
if(Mage::getConfig()->getModuleConfig('Chapagain_AutoCurrency')->is('active', 'true'))
{
$geoIp = Mage::helper('autocurrency')->loadGeoIp();
$ipAddress = Mage::helper('autocurrency')->getIpAddress();
// get country code from ip address
$countryCode = geoip_country_code_by_addr($geoIp, $ipAddress);
$germancountries=array('CH','DE');
if(!isset($_COOKIE['frontstoreloc']))
{
//$siteurl= $this->getUrl();
$siteurl= "http://".$_SERVER['SERVER_NAME'];
setcookie("frontstoreloc",session_id(),time()+60*60*24,"/","");
switch(trim($countryCode))
{
case 'CH':
$url = $siteurl . '?___store=german';
header( 'Location:' . $url);die;
break;
case 'DE':
$url = $siteurl . '?___store=german';
header( 'Location:' . $url);die;
break;
case 'IN':
$url = $siteurl . '?___store=english';
header( 'Location:' . $url);die;
break;
default:
$url = $siteurl . '?___store=usa';
header( 'Location:' . $url);die;
break;
}
}
}

No comments:

Post a Comment