Deniro
Easily convert an amount between two currencies, using live exchange rate data.
Overview
Download
Deniro, v1.1.0
(ZIP, 2KB)
Deniro makes it trivially easy to convert any amount between two currencies, using live exchange rate data from xurrency.com.
The use of live exchange rate data makes Deniro a simple, convenient option for sites that sell products in a single currency, but want to provide guideline equivalent prices for international shoppers.
Requirements
Deniro requires PHP5.
Installation
- Extract the ZIP file.
- Copy
system/plugins/pi.deniro.phpto your/system/plugins/folder.
Usage
To convert an amount between two currencies, just add the plugin to your ExpressionEngine template, as follows:
{exp:deniro:convert amount='123.45' base='GBP' debug='yes' decimal_point='.' precision='2' target='USD' thousands_separator=','}
The convert method accepts the following parameters.
| Parameter | Description | Required? |
|---|---|---|
amount |
The figure to be converted from the “base” currency to the “target” currency. | Yes |
base |
The 3-letter currency code for the base currency. | Yes |
debug |
Set to ‘yes’ to receive detailed debugging information. Default value is no. | No |
decimal_point |
The single-character string to use as the decimal point. Default is a period. | No |
precision |
The number of decimal places to display. Default is 2. | No |
target |
The 3-letter currency code for the target currency. | Yes |
thousands_separator |
The single-character string to use as the thousands separator. Default is a comma. | No |
Checking if a currency is supported
Xurrency provides a full list of supported currencies. You can also check whether a currency is supported on-the-fly, using the is_supported helper function:
{exp:deniro:is_supported currency_code='GBP'} // true
{exp:deniro:is_supported currency_code='XXX'} // false
Debugging
By default, if the base or target currencies are unsupported, or amount is not a numeric value, an empty string is returned.
Detailed information about the cause of failure can be obtained by setting the optional debug parameter to “yes”. For example:
{exp:deniro:convert amount='123.45' base='GBP' debug='yes' target='XXX'}
Support
Support is provided via this thread on the ExpressionEngine forums.
License
Deniro is made available under a Creative Commons Attribution-Noncommerical-Share Alike 3.0 Unported License. What a mouthful.
In practical terms, this means that you can copy, adapt, and distribute Deniro as much as you like, provided that you:
- Credit the original author (that’s me, folks)
- Don’t use any part of Deniro in a commercial product
- License your code in a similar fashion, so others can continue to benefit from your work
Warranty
Deniro is released as-is, without any warranty, express or implied. The author (Stephen Lewis) will endeavour to offer support to those of you gracious enough to use his addon, simply because he’s an all-round good egg. Should he fall under a bus, or just become excessively busy, support may be slow, and perhaps even surly.
Finally, Stephen Lewis and Experience Internet are not responsible for any mishaps, catastrophes, disasters, spillages, data loss, or hair loss that may be caused by the installation or use of Deniro. It’s worked great for us, but your experience may differ.
Change log
- 1.1.0
- Renamed to Deniro (was SL Currency Converter).
- Tidied up code. A lot.
- Added
decimal_point,precision, andthousands_separatorparameters toconvertmethod.
- 1.0.1
- Implemented change log.
Need a custom ExpressionEngine addon?
Find out about our ExpressionEngine development services.