Currency Fields – Formatting not working
-
When adding a currency block and then changing the formatting (settings > Formatting) to ‘123,456.00’ for instance, the email version doesn’t reflect the formatting and instead just shows it as ‘123456.00’ (no comma separation).
-
Hi @primeoak
I hope you are doing well today.
I was not able to replicate this issue on my lab site with USD currency.
Can you:
- let us know what kind of currency you have used?
- export your form, upload it to Google Drive or paste code on Pastebin, and share a link in your next reply so that we can review that on our side?
Kind Regards,
KrisHi Kris
I’m currently using United Kingdom (GBP) for the currency type. I’ve included in the Google Drive folder some screenshots to help show the issue we’re having. You can see the other fields with similar formatting are outputting the commas correctly but the currency isn’t, although set the same.
https://drive.google.com/drive/folders/1uJi3BipTw4vY_ZR82uYVMbLWg1B4ulH7?usp=sharing
Let me know if you need anything else.
Kind regards
Jon
Hi @primeoak
I tested once more on my lab with GBP and I’m not able to replicate this still. It seems something is in your form in which I can see main issue. I have escalated this case to our SLS Team to review this.
We will post an update here as soon as more information is available.
Please keep in mind that our SLS Team deals with more complicated issues, so it may take a little longer for them to reply here. Thank you for your patience while we look into this further.
Kind Regards,
KrisHello @primeoak,
I hope things are going well for you.
This is more like a bug. The team is able to replicate the issue, and the Second Level Team reviewed the case and shared the hotfix with us, which we can use as a mu-plugin on the site until the Forminator team resolves it in the upcoming version.
add_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_currency_value_fix', 10, 5 ); function wpmudev_currency_value_fix( $message, $custom_form, $data, $entry, $cls_mail ) { if ( 47662 !== intval( $custom_form->id ) ) { // Please change the form ID. return $message; } foreach ( $data as $key => $value ) { if ( false !== strpos( $key, 'currency' ) && ! empty( $data[ $key ] ) ) { $field = Forminator_API::get_form_field( $custom_form->id, $key, true ); $formatted_value = Forminator_Field::forminator_number_formatting( $field, $value ); if ( ! empty( $field['currency'] ) ) { $formatted_value = str_replace( $field['currency'], '', $formatted_value ); } $message = str_replace( $field['placeholder'] . $value, $field['placeholder'] . $formatted_value, $message ); } } return $message; }Here are the steps to adding the above script as add mu-plugin to the site.
1. Navigate to File Manager and Look for the public_html directory path or wp-content.
2. under this, you will get the mu-plugins directory; if the folder does not appear, you can create it as mu-plugins.
3. Create a new PHP file, “forminator-fix-currency.php”
4. Paste the code under the above-mentioned .PHP file.
5. Change the form ID 47662 to your form ID, which you’ll get by copying the form shortcode.
6. Save the changes and close the file.If you still need more information on creating mu-plugin, then you can check this guide:- https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Please apply the above script on the staging site before adding it to the main site and share the results with us.
Kind Regards,
Imran KhanHi Imran
Thanks for looking into this for us. I have applied the code as suggested and can now see the correct output in the emails. I look forward to the official plugin update.
One minor thing on the instructions (it temp broke the website), it was missing the opening ‘<?php’ tag for the mu-plugin code as I copied it as instructed above and the site crashed. Turns out the plugins need that snippet at the beginning so it ensures the php is interpreted as code. 🙂
Thanks for your help and speedy response, much appreciated.
Jon
The topic ‘Currency Fields – Formatting not working’ is closed to new replies.