Multi-Currency Support

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Limited approval
Latest version: 
1.05

Downloads


Compatibility: 
Ubercart 1.x

This module enhances Ubercart by allowing a store to display product prices to customers in multiple currencies.

Please read the included README.txt for details and installation instructions. Really. Don't even try to skip this step. There's important information in there, and if you don't follow all the special instructions it won't work.


PreviewAttachmentSize
multicurrency-1.05.tar.gz13.57 KB
Al
Al's picture
Offline
Bug FinderGetting busy with the Ubercode.Internationalizationizer
Joined: 02/14/2008
Juice: 249
Thank you very much, will

Thank you very much, will test it at once tonight Smiling

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Thanks.

quote from permalink

TR wrote:

The IP-based determination of country is a different module, completely separated from the multi-currency function. They are two distinct non-interacting modules.

Can multi-currency support and ip-based be used together so that a visitor from Europe can automatically sees the price in Euro and a visitor from USA sees it in USD?

Can this be integrated with i18n?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Thanks.

Yes, they can be used together. Works well.

I don't know how the i18n module works, and I haven't tried it. Multi-currency only needs a mechanism for a user to choose a country, or to have Drupal determine the country automatically. That mechanism could be the Profile module, or could be something provided by the Internationalization module, or could be something else like the IP-based determination of country. In any case, integration is easy.

Does i18n deal with country information or just language information? Knowing the customer's language is "English" is not enough to figure out what currency to use. The currency could be US Dollars, Canadian Dollars, British Pounds, even Japanese Yen for an English-speaker living in Japan, etc. ...

<tr>.
svihel's picture
Offline
Joined: 05/29/2008
Juice: 140
Re: Re: Thanks.

I tried this, but unfortunately I have got an error after activating the module:

Fatal error: Cannot redeclare uc_currency_format() (previously declared in C:\wamp\www\drupal-5.10\sites\all\modules\ubercart\uc_store\uc_store.module:1855) in C:\wamp\www\drupal-5.10\sites\all\modules\multicurrency\uc_multicurrency.module on line 987

and this after refresh:

Fatal error: Cannot redeclare uc_currency_format() (previously declared in C:\wamp\www\drupal-5.10\sites\all\modules\multicurrency\uc_multicurrency.module:881) in C:\wamp\www\drupal-5.10\sites\all\modules\ubercart\uc_store\uc_store.module on line 1878

I'm using drupal 5.10, ubercart 1.3 (and the needed modules - token, workflow_ng, ubrowser, tapir) and currency module(is it the right currency module?).

Any suggestions?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Re: Re: Thanks.

You obviously didn't read the README.txt. Let me repeat myself:

TR wrote:

Please read the included README.txt for details and installation instructions. Really. Don't even try to skip this step. There's important information in there, and if you don't follow all the special instructions it won't work.

<tr>.
svihel's picture
Offline
Joined: 05/29/2008
Juice: 140
Re: Re: Re: Re: Thanks.

Geez, sorry for wasting your time with stupid question Sad
I did read your note, but before I returned back to this module after some other work I totaly forget about it. It works now.

eugef@drupal.org's picture
Offline
Joined: 12/24/2007
Juice: 102
How directly switch currencies

This module is very great - but i have one big trouble with it

My shop trade only in ONE country and my customers want to chose THREE different currencies. But i ddin't find any way to directly switch bettween currencies.

So, how can i implement a select-list with all currencies, which available on site?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: How directly switch currencies

The intent behind this module is to let the business owner, not the customer, determine which currencies can be used. It is based on the country because currencies are issued by countries, and the law in each country determines what currency is a legal tender (i.e. *must* be accepted as payment in that country). Accepting payment in a currency that is not legal tender in the store's country will cost the store money, because of conversion fees. Just because a store in the US for instance will accept payment in Euros from a customer in France doesn't mean the store wants to accept Euros from a customer in the US! The currency alone, without consideration of country, is not enough choice for the business owner. There are also other laws for exporting and importing goods which may restrict which countries you can sell and ship to, regardless of currency. That is why the choice of currencies must be in the hands of the business owner and is naturally intertwined with the choice of countries you sell to - it is a business decision. This module lets you sell to other countries and still control which currencies you will accept from those countries.

There *is* an assumption in this module that you will only want to accept one currency from any one country. Do you really have three legal currencies in your country? If so, the easiest way to deal with that is to create three .CIF files for your country, with the currency appended to the name. For example, "Switzerland - Swiss Franc", "Switzerland - Euro", "Switzerland - US Dollar". Then you can use the built-in mechanism of this module to allow your customers to choose which one of these three they want to use, and still control the currencies used and the countries you sell to.

I have not made any provision for choosing multiple allowed currencies per country, but if that is a common need I will consider adding it.

<tr>.
eugef@drupal.org's picture
Offline
Joined: 12/24/2007
Juice: 102
Thanks for advice!

My country (Russia) doesn't have three legal currencies. But the owner of a shop just wants to show prices in 3 currencies.
And your module can do this in a greate way.

Thanks for advice!

But the best way - it will be a simple block with direct currency select.
When can you do this functionality?

eugef@drupal.org's picture
Offline
Joined: 12/24/2007
Juice: 102
One more question

I find out that unauthorized user can't change currency because module saves user selection in $user variable.

I think - it will be very usefull to allow all user to change currency.
For unauthorized users module can save their choice in cookie - like uc_cart saves carts.

MrTweed's picture
Offline
Joined: 09/10/2008
Juice: 2
Using Multi-Currency module for handling VAT

I am setting up a Swedish B2C site selling british country clothing to mostly, but not only, scandinavians. Prices in catalog, checkout etc to european customers must be shown swedish VAT (moms) included, but to for instance Norway and and US prices should be shown without VAT. I know this module is not intended for VAT issues, but what do you think about this idea:

Default currency will be SEK including 25% VAT. This means prices will be managed including VAT. Fortunately for the goods in this store there is only one VAT rate. The tax-module will not be used. For EU-customers currency (Euro, DK etc) will be converted at the market rate. For non-EU customers (who should not pay VAT) currency (NOK, USD etc) will be converted using a multiplicative factor to deduct VAT (NOK Price = SEK Price * exchange rate * 80%). The names of the currencies will be set to include VAT information (for instance "SEK incl. VAT" and "NOK excl. VAT").

A couple of things has to be solved to make it work:

1. The VAT amount (20 % of the total order value including shipping) must be shown at the order review and invoice (and preferably at the checkout) for EU customers, but not for non-EU customers. The VAT amount should not be added to the total order value of course. I think we can do this by some dirty coding in the core. Does anyone have a better idea?

2. Anonymous users must be able to see the prices, at least in the default currency. I did not quite understand what modification to the core Ubercart function uc_currency_format()that is needed to do that, as mentioned in the readme-file. Preferably anonumous users should be able to choose currency, but this does not seam possible with this module in present state.

3. The currency (and VAT in this case) available for users at checkout should be controlled by the billing adress. Customers must not be able to buy goods in any other currency because VAT free orders can legaly be given only to non EU-citizens. When an anonymous user chooses billing adress the Currency (and VAT in this case) must be changed accordingly from the default currency, and the cart must be recalculated. How does the Multi-currency module handle this?

4. The payment module must be able to export the currency seleced and the order payment details accordingly, thus be fully integrated with the Multi-currency module. I am checking out if this is possible.

I would be most gratefull for any comments on this approach. And if anyone has a better idea for handling VAT and currencies please let me know.
Regards,
Karl Oskar

Al
Al's picture
Offline
Bug FinderGetting busy with the Ubercode.Internationalizationizer
Joined: 02/14/2008
Juice: 249
Re: One more question
eugef@drupal.org wrote:

I find out that unauthorized user can't change currency because module saves user selection in $user variable.

I think - it will be very useful to allow all user to change currency.

@TR: I would strongly prefer to save the selected country in $_SESSION['country']. Then you could first check if $_SESSION['country'] is set, else fall back to the store's country and it works also before login.

kommurub's picture
Offline
Joined: 09/18/2008
Juice: 6
Option for customers to switch between the currencies

Thanks to the author of this module for putting together all the complex requirements in a user friendly way Eye-wink

It would be super, if you can add the option for customers be able to switch between different currencies.

Of late we've realised this requirement is getting common now a days, most of our business clients needed this feature. Thanks

cloudmine's picture
Offline
Joined: 07/16/2008
Juice: 72
Re: Multi-Currency Support

Can this module show the prices calculated according to a rate of exchange?

F.e. I would always like to input prices in EUR, but calculate them automatically on a daily basis ('how' is another question, I'm just asking what exactly this module does) and show to a visitors who will choose USD in USD and for those who will choose SEK in SEK, etc.

Does anyone tried to integrate it with other Drupal modules, like Profile or i18n?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Quote:Can this module show
Quote:

Can this module show the prices calculated according to a rate of exchange?

F.e. I would always like to input prices in EUR, but calculate them automatically on a daily basis ('how' is another question, I'm just asking what exactly this module does) and show to a visitors who will choose USD in USD and for those who will choose SEK in SEK, etc.

Yes, that's exactly what it does. There are lots of details in the README.txt.

<tr>.
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Re: Quote:Can this module show

I renamed uc_currency_format() to uc_currency_format_original() in uc_store.module. There were around 6 places where uc_currency_format was defined where I added _original in front of it. But when I try to access my drupal website I'm getting
Fatal error: Call to undefined function uc_currency_format() in /home/himag/public_html/drupal/sites/all/themes/flowers/template.php on line 54

I'm not familiar with php, so I don't know if I renamed functions right in uc_store.module. Or is there a problem in template.php?

What I renamed was something like this in 6 places of uc_store.module:

array('data' => uc_currency_format($order->order_total), 'nowrap' => 'nowrap')),

To

array('data' => uc_currency_format_original($order->order_total), 'nowrap' => 'nowrap')),
TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Re: Quote:Can this module show

No, that's not what you're supposed to do. There is only one place the function is defined, and you just have to rename the entire function definition. See my reply to http://www.ubercart.org/issue/6886/installation_readme_file.

<tr>.
crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
Theming question

Hi!

Great module, even better documentation!

I have a theming question, I use a template on my product pages but for some reason when the template is enabled, the price is not changing when I try to switch country from the block. It does work great when the template is not enabled. I use $node->sell_price to display the price.

Any help would be great!

Thanks,

Rob

crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
Ok, answering my question

Ok,

answering my question and maybe helping people struggle with the same issue:

<?php $value = $node->sell_price; ?>
<?php $price = uc_currency_format($value); ?>
<h2><?php print $price; ?></h2>

This did the trick for me.

Rob

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Or just <?php print

Or just <?php print uc_currency_format($node->sell_price); ?>

<tr>.
crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
Obviously I'm in GMT time

Obviously Smiling

I'm in GMT time zone and a bit tired now...

Thanks anyway

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Thanks TR. This time I

Thanks TR.

This time I renamed only the main one function as described by you but now I'm getting a Fatal error: Call to undefined function uc_currency_format() in /home/himag/public_html/drupal/sites/all/modules/ubercart/uc_catalog/uc_catalog.module on line 995

And also I'm using [function phptemplate_uc_cart_block_content] in phptemplate which has uc_currency_format() so I'm also getting Fatal error: Call to undefined function uc_currency_format() in /home/himag/public_html/drupal/sites/all/themes/flowers/template.php on line 54

I'm not getting how to make this work?Sad

peter777's picture
Offline
Joined: 10/13/2008
Juice: 4
unregistered customers need to see prices

Hi
On my webpage, unregistered customers need to see prices in diferent currency without registration. Is it possible to do that without registration? Tahnx for reply

peter777's picture
Offline
Joined: 10/13/2008
Juice: 4
it doesn't work, help please

Hi
I read this in readme.txt file:
Because Drupal caches pages for anonymous users, the only way to handle
displaying multiple currencies to different anonymous users is to turn off
caching entirely (which I don't recommend)
I've got page cache disabled.
And it doesn't work.

Also this doesn't work:
Anonymous users see prices using the default store currency. My anonymous users can see the prices only in USD currency. When I setup Default Country: Slovak republic or some other country it just doesn't work. It still shows in USD but in country selection block is the right country. When anonymous users try to change country selection to some other country afrer submit it will show in block default store currency.

When I log in everything is perfect. I don't understand what I do wrong.

Could anybody help me please?
Thank you

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: it doesn't work, help please

That quote is out of context - this module does not display different currencies for anonymous users under any circumstance. The currency that anonymous users see is determined by the settings at admin/store/settings/multicurrency and admin/store/settings/multicurrency/countries. You have to set the default country to be used for anonymous users and the currency to use for that country. Then you should flush your page cache so that pages are rebuilt using these new settings.

<tr>.
venkat-rk@drupal.org's picture
Offline
Joined: 03/19/2008
Juice: 205
Re: Multi-Currency Support

It would be great if this module could be renamed uc_multicurrency, the way many (most?) other contrib modules are.

venkat-rk@drupal.org's picture
Offline
Joined: 03/19/2008
Juice: 205
Re: Re: it doesn't work, help please

Given that one of the Ubercart's great features is anonymous checkout, wouldn't it be useful to consider having this work module for anonymous users as well?

venkat-rk@drupal.org's picture
Offline
Joined: 03/19/2008
Juice: 205
Re: Multi-Currency Support

Thanks for this great module. Smiling

I read the README.txt and one thing that's still confusing to me is whether renaming the function in uc_store module of ubercart core would make upgrades difficult.

ManuelMendoza's picture
Offline
Joined: 10/30/2008
Juice: 2
Re: Multi-Currency Support

I need the multicurrency functionality for anonymous users, any directions on modifying the module to accomplish that?

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Re: Re: Multi-Currency Support

@venkat-rk, actually when upgrading to new UC, one has to rename uc_currency_format() funcion in the uc_store.module.

@ManuelMendoza, this is an awesome contribution to UC. i would also love to see multi-currency and ip-based module converted to anonymous functionality.

panji's picture
Offline
Joined: 10/31/2008
Juice: 14
D6 Port for Multi Currency

Please make D6 port for it..

Thanks

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Compatibility for all currencies that paypal accepts?

Does this work with paypal?

I've selected Australian Dollar and it is showing perfectly through out the website but when I click on "submit order" on checkout page which took me to paypal website, where the Australian Dollar (AU$ 50 in uber store) converted to United States Dollar (US$ 50 in paypal website)? This is kinda wired....I was expecting that paypal website will show same prices in Australian dollar rather it showed same amount in USD and didn't even re-converted currency...

In admin/store/settings/payment/edit/methods currency code is selected as USD. Is there a way in which a user can choose the currency in which they want to make payment?

Currently paypal accept payments in 18 currency which I would like to integrate in uber store. At least 5 major currencies. Does anyone know how to integrate them with paypal.....

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Compatibility for all currencies that paypal accepts?

This is an issue that can arise with payment modules, and is mentioned in the README.txt for the Multicurrency module. Specifically, the Multicurrency module has no control over how the payment modules are coded, and as many/most are coded without regard to multiple currencies, an examination of the payment module is necessary to ensure that you send the correct amounts/currencies to the payment processor.

The PayPal module has its own variable, set in the admin pages for that module, which controls what currency is used for the transaction. If you want to accept PayPal payments in different currencies, you will have to modify the PayPal module. The lines you need to change are the ones starting with 'CURRENCYCODE'. Right now they take the currency code value from the PayPal module variable. You will have to change this to use the currency code provided by the Multicurrency module. I don't have time right now to design and test a patch for the PayPal module.

<tr>.
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
thanks again, TR. I hope you

thanks again, TR.

I hope you would consider making a patch or integration in near future for above issue. Smiling

G
G's picture
Offline
Joined: 11/11/2008
Juice: 15
Re: Compatibility for all currencies that paypal accepts?

This is fairly easy to fix. In sites/all/ubercart/payment/uc_paypal, modify uc_paypal.module as follows:

in function uc_paypal_wps_form($order), add these lines:

$mycountry = uc_multicurrency_get_country();
$mycurrency = variable_get('uc_multicurrency_country_currency_'.$mycountry, 'USD');

(make sure the above lines are inserted before the following lines):
$data = array(
// PayPal command variable

Then comment out this line:
'currency_code' => variable_get('uc_paypal_wps_currency', 'USD'),

and replace it with this:

'currency_code' => $mycurrency,

Seems to work fine for me.

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 298
Re: Re: Compatibility for all currencies that paypal accepts?

Thank you so much "G". It worked like a charm.

exskool's picture
Offline
Joined: 12/02/2008
Juice: 2
Paypal currency code not supported

My country currency code (MYR) is not supported in paypal. Is it possible to do conversion from MYR to SGD or MYR to USD for the total payment whenever a customer choose to pay with paypal? Currently the payment for MYR10 will be processed as SGD10 in paypal which is definitely wrong..Thanks

G
G's picture
Offline
Joined: 11/11/2008
Juice: 15
Select currency rather than country in dropdown

We have a requirement to allow the user to switch currency, rather than country when displaying prices. We're selling files for download, so it doesn't really matter what country they are in as there is no shipping costs involved. We need to accept payments in GBP, EUR and USD, so to do this, in admin/store/settings/multicurrency/countries, I set all countries to GBP (the store default), except Ireland, which I set to EUR and United States, which I set to USD. I then changed the hook so that the user selects a currency rather than a country (note that I've hardcoded them as a quick workaround, so if you need other countries, you'll need to modify that bit of the code):

<?php
/**
* Currency selection hook
*/
function uc_multicurrency_block($op = 'list', $delta= 0, $edit = array()) {
  switch (
$op) {
    case
'list':
     
$blocks[0]['info'] = t('Currency Selection');
      return
$blocks;

    case

'view':
     
$block['subject'] = t('Currency Selection');
     
$block['content'] = drupal_get_form('uc_multicurrency_currency_select_form');
      return
$block;
  }
}

/**
* Currency selection form
*/
function uc_multicurrency_currency_select_form() {
  global
$user;

 

$current_selection = uc_multicurrency_get_country();

  if (

$current_selection == 'IE')
  {
     
$selected = 3;
  }
  else if (
$current_selection == 'US')
  {
     
$selected = 2;
  }
  else
  {
     
$selected = 1;
  }

 

$form['currency_selection'] = array(
   
'#type' => 'select',
   
'#title' => 'Currency Selection',
   
'#options' => array(1 => 'GBP', 2 => 'USD', 3 => 'EUR',),
   
'#default_value' => $selected,
  );
 
$form['select_button'] = array(
   
'#type'     => 'submit',
   
'#value'    => t('Apply'),
);

 

$current_selection = uc_get_country_data(array('country_iso_code_2' => uc_multicurrency_get_country()));

  return

$form;
}

/**
* Submit handler for currency selection form
*/
function uc_multicurrency_currency_select_form_submit($form_id, $form_values) {
 
$result = $form_values['currency_selection'];
 
uc_multicurrency_set_currency($result);
}

function

uc_multicurrency_set_currency($currency) {
  global
$user;

  if (

$user->uid) {  // Only for logged-in users
   
if ($currency == 2) {
     
$country = 'US';
    }
    else if (
$currency == 3) {
     
$country = 'IE';
    }
    else {
     
$country = 'GB';
    }

   

user_save($user, array('country_iso_code_2' => $country));
  }
}
?>

Note that you'll need to comment out:
the existing version of uc_multicurrency_block()
uc_multicurrency_country_select_form()
uc_multicurrency_country_select_form_submit()

Hope this helps someone.

G

dirkson's picture
Offline
Joined: 06/17/2008
Juice: 53
Re: Multi-Currency Support

Can we get a release for the current version of drupal? I attempted to make this thing go, but my results were hackish at best, and didn't really result in anything more than menu error messages.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Re: Multi-Currency Support

I will not port the module to D6/UC2 until Ubercart has a beta release for D6.

<tr>.
panji's picture
Offline
Joined: 10/31/2008
Juice: 14
UC for D6 goes Beta,.. it's time for Multi-Currency goes to D6

Yess,.. UC for D6 it's now goes to Beta,.. it's 6.x-2.0-beta1 now,.. please create some port for this graet Multi-Currency module....

Thanks b4

dirkson's picture
Offline
Joined: 06/17/2008
Juice: 53
Re: Multi-Currency Support

Trying to make this work in drupal 5, can't seem to get users to switch countries- The block provided doesn't work, and the user billing/shipping address doesn't seem to have any effect on which country they have selected. I heard some talk earlier about IP-based determination- That'd sure be swell, too. How do I actually make this thing switch countries? Any one method would be fantastic.

dirkson's picture
Offline
Joined: 06/17/2008
Juice: 53
Re: Re: Multi-Currency Support

Umm... Hello? Help? I'm sort of dead in the water without input here...

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3452
Re: Re: Multi-Currency Support

Can't help you much if all you say is "doesn't work". Perhaps you're using it as an anonymous user? The accompanying README.txt goes into a lot of details about how this module works and how to set it up. The "IP-based determination of visitor's Country" module is discussed in the README.txt and can be found in the Contributions section.

<tr>.
smb488292's picture
Offline
Joined: 09/16/2007
Juice: 19
Multi-Currency Support

I too would like to see a Drupal 6.x version of this.

Thanks
--
Stephen
Hardfocus Media
Japan

Stephen
Hardfocus Media
Japan

ragavendra_bn's picture
Offline
Joined: 01/10/2009
Juice: 68
Fix Required

Could the fix for Drupa6.x or Ubercart6.x be updated. Multicurrency required for these versions. The changes as per TR has been made. Thou, without Multicurrency it would not work.

sight's picture
Offline
Joined: 01/23/2009
Juice: 4
Re: Multi-Currency Support

Help solve the problem, I need to show 2 the price of goods at the National currency and USD

panji's picture
Offline
Joined: 10/31/2008
Juice: 14
Drupal 6 port pleasee..

yes please... Drupal 6 version please...

Covenant Web Design's picture
Offline
Joined: 01/09/2009
Juice: 132
Drupal 6!

Here's my vote for a Drupal 6 port!

Joshua

Joshua Stewardson
Client Consultant
Covenant Web Design

kelvin's picture
Offline
Joined: 02/12/2009
Juice: 2
Drupal 6 Port

Hello,

I'm nearly done on doing a port for this module, I'll post back soon.

Kwok So
Orange Bus