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

Solution

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

        // get IP Address
        $ipAddress = Mage::helper('autocurrency')->getIpAddress();
        if($this->getIp())
        {
            $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'];
    }
许可以下: CC-BY-SA归因
scroll top