Exchange Rates
This is an Expression Engine module that allows you to get live currency exchange rates.
Support can be found in the comments and in this EE forum thread.
Current Version: 1.1 (released 21 February 2009)
* Works with ExpressionEngine 1.6 and higher.
1. Concept
This module provides the ability to display prices in multiple currencies using live exchange rates. The rates are taken from the European Central Bank website and are updated daily.
2. How It Works
The Exchange Rates module can be called from within a template as well as from an add-on. Every time the module is called it checks if the currency exchange rates have been updated in the last hour. If not then it automatically updates them.
Getting the exchange rate from one currency to another:
{exp:exchange_rates:get_rate from="EUR" to="USD" decimals="5"}
The from parameter is required and represents the currency code of the currency we want to get the rate from.
The to parameter is required and represents the currency code of the currency we want to get the rate to.
The decimals parameter is optional and if included defines how many decimal places the result will have.
Converting a specified amount from one currency to another:
{exp:exchange_rates:convert amount="100" from="USD" to="JPY" decimals="2"}
The amount parameter is required and represents the amount that we want to convert. The amount value can be a field value within a weblog entries tag.
The from parameter is required and represents the currency code of the currency we want to convert from.
The to parameter is required and represents the currency code of the currency we want to convert to.
The decimals parameter is optional and if included defines how many decimal places the result will have.
The module can be called from within an add-on as follows:
// create exchange rate object
if (!class_exists('Exchange_rates'))
{
require '/home/mypath/public_html/system/modules/exchange_rates/mod.exchange_rates.php';
}
$ER = new Exchange_rates();
$USD_to_EUR_rate = $ER->get_rate('USD', 'EUR');
3. Installation
Download and unzip exchange_rates.zip, then follow the steps below:
- Upload the exchange_rates folder to the system/modules folder
- Upload lang.exchange_rates.php to the system/language/english folder
- Install the Exchange Rates module (Control Panel -> Modules -> Install)
4. Download
You can download and use the Exchange Rates module for free here:
If this module has helped you and you are feeling generous then please make a small donation, it is much appreciated:
5. Changelog
Version 1.1- Added decimals parameter


6. Comments
Malcolm
20 February 2009
This is a great module - just downloaded and given it a test - wondered if there was any way to restrict the number decimal places? To 2 (e.g. 12.99)?
Thanks, Malcolm.
Ben
21 February 2009
hi malcolm, great feature request, i've added it to version 1.1 which you can download now.
Malcolm
22 February 2009
Ben - fantastic.
Thanks for the updated version - works a treat :-)
Beebs
03 March 2009
This is great.
My question is How to create a dropdown/pullout option where the parameter "from" and "to" are open so that user can decide which currency need to be converted? - Of course there should be default set in the dropdown/pullout.
Great module!
Beebs
03 March 2009
Sorry for my second post - I thought I will just save time.
The module was installed successfully and I have read your instruction, somehow I confuse to display it in the template.
Can you please give me an example?
Cheers
Ben
04 March 2009
Beebs: to let the user decide the currencies, you would have to set up a form with "from" and "to" currency fields and amount. you could then use php to read in the fields on the submitted form, so you'd have:
<?php global $IN; ?>
{exp:exchange_rates:convert amount="<?php echo $IN->GBL('amount'); ?>" from="<?php echo $IN->GBL('from'); ?>" to="<?php echo $IN->GBL('to'); ?>" decimals="2"}
just make sure that php is enabled and parsed on input.
Danny Tam
06 April 2009
I have a {price} custom field that has the input of "7.99" in it. I have the following Exchange Rates single tag in my template:
{exp:exchange_rates:convert amount="{price}" from="CAD" to="USD" decimals="2"}
It is throwing out this error when I visit my site:
"The following errors were encountered:
Exchange Rates Module: Amount, From and To are all required template variables"
Any ideas?
Danny Tam
06 April 2009
I've resolved the issue. The problem is that I had used the {price} field in my weblog entries list and not every entry had the {price} field populated.
Can you possibly make a parameter that can omit the error page so whatever entries who don't use the field won't get their content displayed.
Or do you think it's just better to use a conditional, such as:
{if price !=''}
{exp:exchange_rates:convert amount="{price}" from="CAD" to="USD" decimals="2"}
{/if}
Danny Tam
06 April 2009
Dear Ben,
I've tried the conditionals as is (above) and it seems even if the code is inserted into conditionals and I visit a weblog entry with it inserted, it will still throw me an error.
I use the same standard template for all my weblog entries, so having a parameter to disable the error page would be great. I thought the conditional would've worked, but I was wrong!
Any solutions is appreciated. Excellent work once again (as with your sitemap module, of which I am a customer).
Ben
06 April 2009
hi danny,
strange that the conditional didn't solve it, can you try the following:
{if "{price}" !=""}
{exp:exchange_rates:convert amount="{price}" from="CAD" to="USD" decimals="2"}
{/if}
Mike
19 September 2009
Could this module work in a wordpress blog which is rebuild to a webshop?
Let's say I wanna fetch all input data in posts/pages that looks like this:
8.00 USD
And get the live currency rate for UK Pounds displayed:
4 GBP
If not this module can do it, any tips on plugins, scripts that might handle such actions?
Kindly
Mike
Ben
20 September 2009
hi mike, first of all this module is for expression engine, not wordpress. but yes it can convert an amount for you.
Michael C.
14 October 2009
Would I be mistaken if I gathered that this module doesn't automatically update the rates on a regular basis, or when called, or anything - that updates are only done manually through the module configuration page?
Michael C.
14 October 2009
Erk, nevermind. RTFM, me!
Grumpy
15 May 2010
hi Ben
This doesn't work for me to:
{if "{price}" !=""}
{exp:exchange_rates:convert amount="{price}" from="CAD" to="USD" decimals="2"}
{/if}
Ben
17 May 2010
what happens when you try that?
Best Currency Rate
07 June 2010
This is a wonderful opinion. The things mentioned are Great and needs to be appreciated by everyone.
Best Currency Rate
Best Currency Rate
07 June 2010
This is a wonderful opinion. The things mentioned are Great and needs to be appreciated by everyone.
Best Currency Rate
Rowan
30 June 2010
Hey,
I’m not sure whats up- but this isn’t working for me.
I installed it no problem, and I tried using it with the two default examples, and it didn’t actually work.
I get this error:
* Exchange Rates Module: From or To currency not found
Can you help me?
Here’s my template code.
{exp:exchange_rates:get_rate from="EUR" to="USD" decimals="5"}
and
{exp:exchange_rates:convert amount="100" from="USD" to="JPY" decimals="2"}
Is there some dependency, requirement that would be preventing this from working?
I’m running EE 1.6.6
Thanks.
Adrian Walls
20 July 2010
Any chance this module will be available for EE 2.1?
Adrian Walls
20 July 2010
Any chance this module will be available for EE 2.1?
» View more comments
Leave A Comment