Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 2
Automatic currency change with each country specific IP address. 
 
valajbeg
Jr. Member
 
Total Posts:  23
Joined:  2009-11-04
 
phlux0r - 29 October 2009 11:48 AM

If you’re running a single store/store view only and have the currency selector available and want to set the default currency depending on GeoIP, then I have a slightly different solution to the one dd_gi posted here: http://www.magentocommerce.com/boards/viewreply/179902/

My solution sets the default currency depending on geoIp and still allows the visitor to change the selection in the currency drop-down. There are no redirects either.

What I’ve done is basically override Mage_Core_Model_Store->getDefaultCurrencyCode() and use the geoIp functions to determine the currency I want selected based on the visitor’s country.

When a visitor comes to the site, their currency will be set according to their country/region but they will still be able to change it. Once they change it, their session cookie will be updated and the changed currency kept for the browsing session.

Hope this helps someone.

@phlux0r,
could you give us more input about that, or even paste some code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
phlux0r
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-09
Auckland, New Zealand
 

Here’s my override:

class Lero9_Lero9custom_Model_Store extends Mage_Core_Model_Store
{
    
public function getDefaultCurrencyCode()
    
{
        
// by default we look for the configured currency code
        
$result $this->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT);        
        
// however, in our case we want to determine the default currency depending on the country/continent of the visitor
        
$geoCountryCode null;
        try 
{
            $geoCountryCode 
geoip_country_code_by_name$_SERVER['REMOTE_ADDR');
        
catch (Exception $e{
            
// prevent NOTICE error and do some error handling
        
}
        
// first tier check is the specific countries to set the currency for
        
switch ($geoCountryCode{
            
case "AU":
                
$result "AUD";
                break;
            case 
"GB":
                
$result "GBP";
                break;
            case 
"JP":
                
$result "JPY";
                break;
            default:
                
$geoContinentCode null;
                
// now grab the contintent code and set further by region
                
try {
                    $geoContinentCode 
geoip_continent_code_by_name$_SERVER['REMOTE_ADDR');
                
catch (Exception $e{
                    
// prevent NOTICE error
                
}

                
switch ($geoContinentCode{
                    
case "EU":
                        
$result "EUR";
                        break;
                    case 
"NA"// North America
                    
case "SA"// South America
                    
case "AS"// Asia
                    
case "AF"// Africa
                        
$result "USD";
                        break;
                    default:    
// everything else uses the default store currency as set in config
                
}
        }
        
return $result;
    
}
}

Note that I’m using the GeoIP PHP module and that my process is specific to setting the currency for certain regions according to our own rules.

Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
valajbeg
Jr. Member
 
Total Posts:  23
Joined:  2009-11-04
 

ok, i see it and i like it.. i have my rules too

thank you very much

 
Magento Community Magento Community
Magento Community
Magento Community
 
Fivell
Jr. Member
 
Total Posts:  1
Joined:  2010-04-12
 

Thnks
My implementation for this using apache mod_geoip

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bart Simpson
Jr. Member
 
Total Posts:  14
Joined:  2010-03-11
 

None of the above helped me, I needed website level pricing as the auto-converted prices were not easy on the eyes.

I updated the wiki with what may be an easier solution:

http://www.magentocommerce.com/wiki/multi-store_set_up/multiple-website-setup

 
Magento Community Magento Community
Magento Community
Magento Community
 
chapagain
Sr. Member
 
Avatar
Total Posts:  202
Joined:  2009-07-19
 

Here is a free module for auto currency change with each country specific IP address:-

Auto Currency Switcher

Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ian M
Jr. Member
 
Total Posts:  25
Joined:  2008-01-16
 

Hi Chapagain,

Many thanks for your free Auto Currency Switcher module. I’ve installed it but can’t see any setting within System --> Configuration.

Should there be some module setting? Also is there an easy way to test different IP addresses to trigger the different currencies?

Thanks,
Ian

 
Magento Community Magento Community
Magento Community
Magento Community
 
Fredddd
Jr. Member
 
Total Posts:  2
Joined:  2011-05-25
 

Hi Chapagain
Your module seems handy, but here’s a question:

does it take currency rules from main Magento settings? can I edit currency matching IP range within the module?

 
Magento Community Magento Community
Magento Community
Magento Community
 
FMEExtensions
Mentor
 
Avatar
Total Posts:  1298
Joined:  2009-08-07
 

Currency can be made country specific with the following

http://www.fmeextensions.com/magento-geo-ip-default-language-currency.html

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 2