Using Gravity Forms ‘gform_currencies’ PHP action

The gform_currencies filter allows you to update existing currencies and/or create new currencies in Gravity Forms.

Usage

add_filter('gform_currencies', 'update_currency');

Parameters

  • $currencies (array): An array of registered currencies using the three character ISO 4217 currency code as the key to the currency properties.

More information

See Gravity Forms Docs: gform_currencies

Examples

Update Euro

This example demonstrates how to change the EUR symbol to the left.

add_filter('gform_currencies', function($currencies) {
    $currencies['EUR']['symbol_left'] = '€';
    $currencies['EUR']['symbol_right'] = '';
    return $currencies;
});

Add Indian Rupee

This example demonstrates how to add a new currency.

add_filter('gform_currencies', function($currencies) {
    $currencies['INR'] = array(
        'name'               => __('India Rupee', 'gravityforms'),
        'code'               => 'INR',
        'symbol_left'        => '₹',
        'symbol_right'       => '',
        'symbol_padding'     => ' ',
        'thousand_separator' => ',',
        'decimal_separator'  => '.',
        'decimals'           => 2
    );
    return $currencies;
});

Remove the space after the currency symbol for Pound Sterling

This example demonstrates how to remove the space after the £ for Pound Sterling.

add_filter('gform_currencies', function($currencies) {
    $currencies['GBP']['symbol_padding'] = '';
    return $currencies;
});

Remove decimals for USD

This example demonstrates how to remove the decimals. Remember that this is a global setting, so it will affect all your products.

add_filter('gform_currencies', function($currencies) {
    $currencies['USD']['decimals'] = 0;
    return $currencies;
});

Note: The code should be placed in the functions.php file of your active theme.

This filter is located in RGCurrency::get_currencies() in currency.php.