Author - Kristof Ringleff

Hi I'm Kristof the founder of Fooman. I will share some of my experiences gained from developing Magento extensions since version 1.0 here on MageBase.

You can see a list of all my open source and commercial extensions on Magento Connect.

More Info »

Reader Comments (26)

  1. Unirgy
    April 6, 2011 at 3:00 pm /

    Hey, thanks for using uGeoIP 🙂

    Do I have your permission to apply the patch for the next version?
    It will be properly attributed.

  2. Vinai Kopp
    April 7, 2011 at 2:09 am /

    This is a great post, but since sometimes the models may be already rewritten I’d thought I’d share an alternative way to get around the rewrites. It’s possible to set configuration values on the fly in observers.
    To use this with geoip lookup results to set the default currency you could do this in an event observer:

    public function controllerFrontInitBefore(Varien_Event_Observer $observer) {
        $geoIpDefaultCurrentyCode = $this->_getDefaultCurrency(... do logic in this method to determine the correct default currency...);
        Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT); // Call once to work around config section caching bug
        Mage::app()->getStore()->setConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT, $geoIpDefaultCurrentyCode); // set geoip value

    And you’re done.

  3. Vinai Kopp
    April 7, 2011 at 4:33 am /

    Here is a patch I submitted some time last year, it hasn’t made it into the core (yet?) though.

    I think I’ll resubmit it now they have the new contributor svn in place, maybe it just got lost…

  4. Setting default values based on GeoIP data – Tutorials – Magebase | Magento Training Course

    […] as well as displaying the correct tax inclusive or tax exclusive prices to your overseas visitors. Link – Trackbacks source: Topsy – magento tutorial – Setting default values based on […]

  5. Toby
    April 9, 2011 at 8:23 am /

    Great post and comments – a who is who of great Magento developers!

    I was only interested in tax calculation and shipping estimate in the shopping cart, so I ened up using an observer on sales_quote_save_before.

  6. Sahil
    April 11, 2011 at 11:21 pm /

    Hi Kristof,

    Can this be used to change the website (store) rather than the currency?

  7. Links 13/2011 bis 15/2011: Magento, Magento und noch einmal Magento | Matthias Zeis

    […] Zenner für t3n: erste Eindrücke zu Magento Go.Magebase: Standardeinstellungen aufgrund von GeoIP-Daten setzen.thebod: Anleitung für ein eigene Versandarten/-Extensions.thebod: gleich hinterher die […]

  8. Daniel
    May 4, 2011 at 3:15 am /

    First of all, thank you very much for this extension

    I only have one problem, if I connect with a Swiss IP, it correctly shows swiss franc as the currency, but once I add an item to the cart the currency is changed to Euro.
    Any idea as to why this keeps happening?

    1. Daniel
      May 4, 2011 at 3:42 am /

      solved it, currency rate for swiss franc wasn’t set

  9. zentaiok
    May 20, 2011 at 9:41 pm /

    Really useful! Your magento tutorial is the most useful I serached at google. Thank you.

  10. jaimin
    August 3, 2011 at 2:08 am /

    can we adjust it for the language i am new in magento and my site requirement is display site on local language of particular country’s so it can be adjust for that if yes then pls guide me how can i do this
    thanks in advance

  11. Shore
    October 6, 2011 at 4:18 am /

    Really helpful post,

    The tax adjustment doesnt work too well in magento 1.2.1 (we’ve upgraded since and everything works great)


  12. Jerome Dennis D
    February 7, 2012 at 8:46 pm /

    Hi Kristof,

    Thanks a lot for this much helpful article.

    BTW i have installed this module from unirgy as well as downloaded and copied the geoip DB and file inside /root/geoip


    And in my index.php file, i am just using the following lines (as i want to use this module and GEOIP library to switch websites based on the visitors country )

    $geoIp = Mage::helper('ugeoip')->getGeoLocation(true);
    $geoCountryCode = $geoIp->getData('countryCode');
    $geoContinentCode = $geoIp->getData('countryContinent');

    however am ended up with the following error:

    Fatal error: Uncaught exception ‘Exception’ with message ‘Unable to open file: /home/httpd/vhosts/’ in /home/httpd/vhosts/

    Am also getting the same kind of error when i try to use the following code below :

    /*GEO IP*/
    define("GEOIP_DAT_FILE", $_SERVER['DOCUMENT_ROOT'] . "/geoip/GeoIP.dat");
    define("GEOIP_INC_FILE", $_SERVER['DOCUMENT_ROOT'] . "/geoip/");
    $_geoip = geoip_open(GEOIP_DAT_FILE ,GEOIP_STANDARD);
    $_country_code = geoip_country_code_by_addr($_geoip, $_SERVER['REMOTE_ADDR']);

    Could you please let me know what am doing wrong ?

    Thanks a lot for reading my comment !!!

  13. Jerome Dennis D
    February 10, 2012 at 4:52 pm /

    Thanks a lot Kristof.

    Its working like a cake now 🙂

    And really sorry to bother you for my very silly mistake.

    Glad am able to switch between different websites using country and continent codes now, with the help of UNIRGY extension and GEOIP.DAT.

    You can see this is in action here

  14. Praful
    September 29, 2012 at 12:10 am /

    Hello ,

    I am also implementing it…

    see …what will happened?…

    but I am sure It will work because it is made by Kristof….


  15. Matt
    March 11, 2013 at 10:36 am /

    Anyone have got this working on 1.7+ ? I installed the extensions successfully but won’t get either currency or default country / tax changes working. I have checked the normals; the logs are clean and there are no conflicts between extensions.

    Is there something in 1.7 that is blocking this great thing?


  16. Rao
    April 25, 2013 at 7:55 pm /


    nice work i followed this in my custom module and it was great help indeed, now i have a question its not related to the code above but is to the store. is it possible to change the store view just like changing currency by ip (using geoip)? i have tried to understand the flow and figured that it start from index.php then to Mage.php and eventually to App.php , App.php is where the store is selected and i can’t overwrite it nor there is an event to alter the scope code to desirable store view code. how can i achieve that?

    thanks in advance.

  17. Steve
    November 23, 2013 at 5:27 pm /


    Does anyone have any ideas how to update tax percentage rules based on GEOIP for Magento 1.8?


  18. Steve
    November 23, 2013 at 5:28 pm /

    We just get this error:

    Fatal error: Call to a member function getCollection() on a non-object in /home/content/64/11792364/html/beta/app/code/core/Mage/Core/Model/App.php on line 618


  19. Best tutorials for Magento | Ken Nguyen

    […] Setting default values based on GeoIP data […]

  20. Chris
    November 11, 2015 at 8:29 am /

    Hi there, this looks like a great extension, however I’ve tried to install it on 1.9.1 and it doesn’t come up with any errors, but doesn’t seem to do anything either. Is there any way to see whether it’s being called, and to tweak it to work with 1.9.1?

    Many thanks!


Add a Comment & Join the Discussion

Insert small snippets of code by using [code]{your_code_here}[/code]
For larger code blocks please use and paste your link.

You may also use the following HTML in your comment: <a href="" title=""> <abbr title="">
<acronym title=""> <blockquote cite=""> <cite> <em> <strike> <strong>


This site uses Akismet to reduce spam. Learn how your comment data is processed.