waCurrency

Processing of currency-related data

Contents...

Methods

public static function getInfo ($currency)

Returns information about a currency by its ISO3 code, which is retrieved from its config file located in wa-system/currency/data/.

Parameters

Example

waCurrency::getInfo ('USD')

Result

Array
(
    [code] => USD
    [sign] => $
    [sign_position] => 0
    [sign_delim] => 
    [title] => United States Dollar
    [name] => Array
        (
            [0] => Array
                (
                    [0] => dollar
                    [1] => dollars
                )

            [1] => US$
        )

    [frac_name] => Array
        (
            [0] => Array
                (
                    [0] => cent
                    [1] => cents
                )

        )

)

public static function format ($format, $n, $currency, $locale = null)

Returns formatted amount value with currency.

Parameters

Example

waCurrency::format ('%0{s}', 123456.78, 'USD', 'en_US')

Result

$123,457

Example

waCurrency::format ('%w{n}', 123456.78, 'USD', 'en_US')

Result

one hundred and twenty-three thousand four hundred and fifty-six dollars

PHP functions

wa_currency ($n, $currency, $format = '%{s}')

Wrapper for method format using current user's locale.

Example

wa_currency (123465, 'USD')

Result

$123 465

wa_currency_html ($n, $currency, $format = '%{h}')

Wrapper for method format used for embedding formatted amount values in HTML code using current user's locale (for currencies having a value for sign_html parameter specified in its config file located in wa-system/currency/data/).

Smarty modifiers

{$amount |wa_format_amount_currency [:$currency_id=null, $locale=null]}

Formats a number as an amount expressed in a currency using the format method. Format string '%{s}' is used.

Example

{'123456'|wa_format_amount_currency:'USD'}

Result

$123 456

{$amount |wa_format_amount_currency_words [:$currency_id=null, $locale=null]}

Formats a number as an amount expressed in a currency using the format method. Format string '%.W{n0} %.2{f0}' is used by default.

Example

{'123456'|wa_format_amount_currency_words:'USD':'en_US'}

Result

One hundred and twenty-three thousand four hundred and fifty-six dollars 00 cents

public static function getAll ($type = 'title')

Returns the list of all available currencies.

Parameters

Example

waCurrency::getAll ('sign')

Result

Array
(
    [JPY] => ¥
    [CLP] => $
    [TRY] => TL
    [VEF] => Bs.F.
    [BSD] => $
    [LTL] => Lt
    ...
    [GYD] => $
    [USD] => $
    [NPR] => Rs.
    [BZD] => $
    [PHP] => P
    [BBD] => Bds$
)