WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Euro FxRef Currency Converter

Adds the [currency] and [currency_legal] shortcodes to convert currencies based on the ECB reference exchange rates.

Shortcode usage & examples

currency_legal shortcode

This shortcode returns the string '* For informational purposes only. Exchange rates may vary. Based on ECB reference rates.'

The prepended '* ' (the same string as the [currency] append string) can be changed using the 'prepend' attribute.

For example: [currency_legal prepend='Please note: ']

legal_string method

The legal string can also be retrieved in PHP

Usage

<?php echo EuroFxRef::legal_string( $prepend ) ?>

Parameters

  • $prepend (string) The string to prepend the legal text with, default '* '

Return Value

(string) Legal text prepended with $prepend string.

currency shortcode

  • from: currency code (default: EUR)
  • to: currency code (default: USD)
  • amount: number of "from" currency (default: 1)
  • iso: boolean (true or false, default false); use ISO currency formatting
  • show_from: boolean (default true); show from amount in output
  • between: string (default '&nbsp;/&nbsp;' which is displayed as ' / ' in the browser); string between from and to amounts
  • append: string (default '&nbsp;' which is displayed as ' ' in the browser); string put after conversion. The * references the disclaimer text, see [currency_legal] shortcode.
  • round: boolean (default true); Round numbers to whole units.
  • round_append: string (default '='); replaces decimals
  • to_style: css formatting text (default 'cursor:help;border-bottom:1px dotted gray;'); styling of "to" text.

Conversion from non-Euro to non-Euro is done through the Euro, so GBP to USD is calculated as GBP -> EUR -> USD.

convert method

Since v1.3, you can call the convertor staticly from PHP in your code.

Usage

<?php EuroFxRef::convert( $amount, $from, $to ); ?>

Parameters

  • $amount (float) The amount of currency you want to convert.
  • $from (string) The currency code the amount is in, default EUR.
  • $to (string) The currency code the amount must be converted to, default USD

Return Value

(float) the converted value or 0 (zero) if any of the currency code's are not available.

Examples

  • [currency amount="875" from="EUR" to="GBP"] becomes "€ 875,= / £ 697.= *"
  • [currency amount="875" from="GBP" to="USD" iso=true between=" converts to " append="" round_append=""] becomes "875 GBP converts to 1,418 USD"
  • [currency amount="875" from="GBP" to="USD" show_from=false round=false] becomes "$ 1,130.15 *"

  • <?php $process_later = EuroFxRef::convert( 10, 'USD', 'GBP' ); ?> will return the raw numeric (float) value without formatting: 6.01877256317689468545495401485823094844818115234375

Currently available currencies

  • EUR Euro (€)
  • USD US Dollar ($)
  • JPY Japanese Yen (¥)
  • BGN Bulgarian Lev (ЛВ.)
  • CZK Czech Republic Koruna (Kč)
  • DKK Danish Krone (kr)
  • GBP British Pound Sterling (£)
  • HUF Hungarian Forint (Ft)
  • LTL Lithuanian Litas (Lt)
  • LVL Latvian Lats (Ls)
  • PLN Polish Zloty (zł)
  • RON New Romanian Leu (RON)
  • SEK Swedish Krona (kr)
  • CHF Swiss Franc (CHF)
  • NOK Norwegian Krone (kr)
  • HRK Croatian Kuna (kn)
  • RUB Russian Rouble (py6.)
  • TRY Turkish Lira (TL)
  • AUD Australian Dollar ($)
  • BRL Brasilian Real (R$)
  • CAD Canadian Dollar ($)
  • CNY Chinese Yuan (元)
  • HKD Hong Kong Dollar ($)
  • IDR Indonesian Rupiah (Rp)
  • ILS Israeli New Sheqel (₪)
  • INR Indian Rupee (₹)
  • KRW South Korean Won (₩)
  • MXN Mexican Peso ($)
  • MYR Malaysian Ringgit (RM)
  • NZD New Zealand Dollar ($)
  • PHP Philippine Peso (₱)
  • SGD Singapore Dollar ($)
  • THB Thai Baht (฿)
  • ZAR South African Rand (R)

Requires: 3.3 or higher
Compatible up to: 3.9.1
Last Updated: 2014-4-17
Downloads: 1,926

Ratings

5 stars
5 out of 5 stars

Support

0 of 1 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.