How to add currency suffix – add USD to end of value

The following code will add “USD” to the end of the U.S. Dollar currency in Gravity Forms.

For example, instead of seeing $34.20 – $34.20 USD is displayed.

This will not affect existing submissions – only newly loaded forms and new submissions.

If you’re not sure where to place this code I highly recommend you read How to create a WordPress plugin for your custom functions.

add_filter( 'gform_currencies', 'gg_gf_usd_suffix' );
function gg_gf_usd_suffix( $currencies ) {
    $currencies['USD'] = array(
        'name'               => __( 'U.S. Dollar', 'gravityforms' ),
        'symbol_left'        => '$',
        'symbol_right'       => ' USD',
        'symbol_padding'     => '',
        'thousand_separator' => ',',
        'decimal_separator'  => '.',
        'decimals'           => 2
    );

    return $currencies;
}

 

This uses the gform_currencies filter that allows you to update or create currencies. See the Gravity Forms documentation for examples of how to use this filter.

Was this article helpful?

Related Articles