Experience Internet is an award–winning web design agency with a 110% money–back guarantee. Call us on 0845 053 3139 to find out more.

Deniro

Easily convert an amount between two currencies, using live exchange rate data.

Overview

ZIP file iconDownload 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

  1. Extract the ZIP file.
  2. Copy system/plugins/pi.deniro.php to 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:

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, and thousands_separator parameters to convert method.
1.0.1
  • Implemented change log.

Need a custom ExpressionEngine addon?
Find out about our ExpressionEngine development services.

EE addons

Other goodies

Copyright © Experience Internet. The header background image is part of Sink or Swim, copyright © Michel Keck.