I am using chapagain/auto-currency-switcher Magento extension to setup auto currency and it's working well in the laptop browser but issue with mobile.

When I am trying to open a website from my mobile browser currency not change automatically it's always display USD

i.e. When i open site from laptop currency change to INR but it's not working on mobile


Same issue with me a day ago problem with model/store.php

I face same issue in a mobile chrome browser


public function getCurrencyCodeIp2Country() 
        // load Ip2Country database
        $ipc = Mage::helper('autocurrency')->loadIp2Country();

        // get IP Address
        $ipAddress = Mage::helper('autocurrency')->getIpAddress();
            $ipAddress = $this->getIp(); // will return real ip

        // additional valid ip check 
        // because Ip2Country generates error for invalid IP address
        if (!Mage::helper('autocurrency')->checkValidIp($ipAddress)) {
            return null;

        $countryCode = $ipc->lookup($ipAddress);

        $currencyCode = Mage::helper('autocurrency')->getCurrencyByCountry($countryCode);

        return $currencyCode;

public function getIp() {
        $ip = $_SERVER["REMOTE_ADDR"];
        if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
           $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
           $ip = $_SERVER['HTTP_CLIENT_IP'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.