October 2nd, 2015: Fixed typo. Parenthesis replaced with curly brace.
<?php | |
/** | |
* Graivty Wiz // Gravity Forms // Move Currency Symbol from the Right to the Left (i.e. "0,00 €" to "€ 0,00") | |
* https://gravitywiz.com/how-do-i-move-the-currency-symbol-from-the-right-to-the-left-for-gravity-forms/ | |
*/ | |
add_filter( 'gform_currencies', 'gw_modify_currencies' ); | |
function gw_modify_currencies( $currencies ) { | |
$currencies['EUR'] = array( | |
'name' => esc_html__( 'Euro', 'gravityforms' ), | |
'symbol_left' => '€', | |
'symbol_right' => '', | |
'symbol_padding' => ' ', | |
'thousand_separator' => '.', | |
'decimal_separator' => ',', | |
'decimals' => 2 | |
); | |
return $currencies; | |
} |
Getting Started
Install the snippet
- Copy and paste the entire snippet into your theme’s functions.php file or install via a code snippet management plugin like Code Snippets.
Configure the snippet
- This snippet moves the Euro’s currency symbol to the left by moving the symbol’s HTML entity from the “symbol_right” property to the “symbol_left” property.
- If you’d like to apply this to a different currency you will need to change the
'EUR'
on line 9 to the appropriate abbreviation for your desired currency. See the tip below for an easy way to find out the correct abbreviation.
For a list of default Gravity Forms currencies and an overview of the available currency parameters, check out the Gravity Forms Currencies resource.
Any questions?
What else do you need to do with Gravity Forms currencies? Let us know in the comments!
Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 29+ essential add-ons for Gravity Forms with support you can count on.
I tip my hat again Sir, FYI Euro standard is a . as a currency separator and , as a thousand. The code above has them flipped. Below is the format for a Euro total field like (€ 0.99 or € 1,000.99)
Hi Niall, I’m no expert on this subject, but my understanding is that you can format the Euro either way depending on your country. Most European countries appear to use the dot for thousands and the comma for decimals.
Also, this snippet doesn’t actually change the decimal or thousands separators from that which is included in core by default for the Euro.
Definitely open to new information on this subject. :)
I was just browsing all the goodies on the site and stumbled upon this one, works like magic. Real easy! Just wanted to thank you!
Glad you’re digging the site, Richard. Make sure you check out Gravity Perks too. :)
There’s a typo in the last line – should be no ), but a closing }.
Thanks, Bob! Fixed.