O'Reilly logo

Building E-commerce Sites with VirtueMart Cookbook by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting the user's country with Sourcerer and GeoIP

What we will do is detect which country a visitor to our website is from and vary the content we show accordingly. In this simple recipe we will detect if a visitor is from UK, Spain, or Germany and output a message in the appropriate language. You will be able to easily adapt or extend the code should you wish to cater for more countries or different countries. This will work by using Sourcerer to query a GeoIP database which tells us where the current visitor's IP address is registered.

Getting ready

If you haven't installed Sourcerer then see the recipe, Installing Sourcerer, in this chapter.

Pick an article, product, category, or Joomla! HTML module in which to do this. We will be installing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required