How to Create a New Currency Symbol for WPForms

Overview

Would you like to create a new currency symbol for your WPForms? WPForms already has many currencies to choose from, however, if you would like to add a new symbol or simply just move the position of an already existing currency symbol, this is easily achievable. This tutorial will walk you through the steps of adding a new currency to your WPForms.

Setup

The code below will add Lira currency as an option under WPForms » Settings » Payments tab. Just add the code snippet below to your site.

/**
 * Add a new currency symbol
 * 
 * @link https://wpforms.com/developers/how-to-create-a-new-currency-symbol-for-wpforms/
 *
 */

function wpf_dev_currencies( $currencies ) {

    $currencies['LRA'] = array(
        'name'                => esc_html__( 'Lira', 'wpforms' ),
        'symbol'              => '₤',
        'symbol_pos'          => 'right', // enter left or right to position the symbol
        'thousands_separator' => ',',
        'decimal_separator'   => '.',
        'decimals'            => 2,
    );
  return $currencies;
}
add_filter( 'wpforms_currencies', 'wpf_dev_currencies', 10, 1 );

You've now used PHP to create a new currency symbol

More Examples

Here are some further examples.

Euro

/**
 * Add a new currency symbol - Euros
 * 
 * @link https://wpforms.com/developers/how-to-create-a-new-currency-symbol-for-wpforms/
 *
 */

function wp_add_currencies( $currencies ) {

    $currencies['EUR'] = array(
        'name'                => esc_html__( 'Euro', 'wpforms' ),
        'symbol'              => '€',
        'symbol_pos'          => 'left', // LEFT
        'thousands_separator' => '.',
        'decimal_separator'   => ',',
        'decimals'            => 2,
    );
  return $currencies;
}
add_filter( 'wpforms_currencies', 'wp_add_currencies', 10, 1 );

Hong Kong Dollar

/**
 * Add a new currency symbol - Hong Kong Dollar
 * 
 * @link https://wpforms.com/developers/how-to-create-a-new-currency-symbol-for-wpforms/
 *
 */

function wp_add_currencies( $currencies ) {

    $currencies['HKD'] = array(
        'name'                => esc_html__( 'Hong Kong Dollar', 'wpforms' ),
        'symbol'              => '$',
        'symbol_pos'          => 'left', // LEFT
        'thousands_separator' => ',',
        'decimal_separator'   => '.',
        'decimals'            => 2,
    );
  return $currencies;
}
add_filter( 'wpforms_currencies', 'wp_add_currencies', 10, 1 );

And that’s it! You’ve now added a new currency to your WPForms. Would you like to know how to change the position of the description? Take a look at our tutorial on How to Position the Field Description Above the Form Field.

Filter Reference: wpforms_currencies

FAQ

Q: How can I move the currency symbol?

A: In this example, we’ll move the U.S. Dollar (USD) symbol from the left to the right using the following snippet.

/**
 * Add a new currency symbol
 * 
 * @link https://wpforms.com/developers/how-to-create-a-new-currency-symbol-for-wpforms/
 *
 */

function wpf_dev_currencies( $currencies ) {

    $currencies['USD'] = array(
        'name'                => esc_html__( 'U.S. Dollar', 'wpforms' ),
        'symbol'              => '$',
        'symbol_pos'          => 'right', // left or right
        'thousands_separator' => ',',
        'decimal_separator'   => '.',
        'decimals'            => 2,
    );
  return $currencies;
}
add_filter( 'wpforms_currencies', 'wpf_dev_currencies', 10, 1 );

Now the symbol has been moved from showing on the left to showing on the right.

Simply by adding the ‘symbol_pos’ => ‘left’, or ‘symbol_pos’ => ‘right’, you are moving the position of the currency from one side to the other.