Hey,
I have used ip2locale module for a project, and had the inquiry to also select currency based on user country / IP.
There are 2 approaches:
1. Make a custom module with same functionality as ip2locale but match currency
2. Integrate currency matching inside ip2locale module (since locale means language, currency etc)

I used the first approach since I want to be completely independent, but if this would get to ip2locale releases I believe it would be more easy.
The basic functionality is to map country code to currency code, like:
fr,eur
us,usd
...

And currently currency is saved in a $_SESSION variable named 'currency' wich also can be defined in admin.

Let me know what you think, and if there could be any reason / interest in having this in ip2locale releases.

Thanks,
Gabriel

CommentFileSizeAuthor
ip2currency.tar_.gz5.75 KBgabrielu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gabrielu’s picture

Please let me know what you think? Could we find a merge solution or can I take your code to a new separate project?

mrfelton’s picture

Status: Active » Fixed

I had a similar request a while ago on one of the sites that I work on, and I developed a module to allow you to associate a currency with each locale. I've just uploaded it to drupal.org - http://drupal.org/project/locale_currency

gabrielu’s picture

Status: Fixed » Needs review

Actually, I see your module associates a currency to each locale, my catch would be to auto-assign currency based on user IP.
The scenario is:
We have a site in 2 languages (English and French) and products available in USD, EUR and GBP.
We would assign a UK user (based on IP) the Language English and currency GBP.

I think it's a nice module but it's not what I was thinking.
Maybe we can have a IP API, a module to trigger a hook or action based on user IP, and other modules can be plugged in to take action based on user location.

Later edit
Actually I see GeoIP provides something similar to what I am referring above.

mrfelton’s picture

Status: Needs review » Postponed (maintainer needs more info)

but surely your UK user would be viewing English nodes, and so when viewing those nodes, $language->currency would be set to GBP. Likewise, your French user would be viewing French nodes, and so when viewing those node $language->currency would be set to EUR..?

gabrielu’s picture

Status: Postponed (maintainer needs more info) » Active

Right, but my US user will be viewing English nodes and $language->currency would be set to GBP ?? Or my German viewer that might fall back to English since I don't have translations for German and will also have GBP as currency?

This is my case.

mrfelton’s picture

Right, I get what you're saying.

Do you know of a definitive list of country->currency codes?

gabrielu’s picture

There should be something like http://www.nationmaster.com/graph/eco_cur_cod-economy-currency-code but I think it's best to let the user have the option to select, depending on the available currencies on his site.