Skip Navigation

[Resolved] Display a number field with thousand separator and currency

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Jean Rapenne 1 year, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2548159

Hi,

I need to display a "Number" field with thousand space separator, two decimal, and currency symbol.

Needed display: 1 000 000,25 €

Regards.

Jean

#2548585

Hello,

There isn't such kind of built-in feature, it needs custom codes, for example, you can try these:
1) Create a custom shortcode with a custom PHP function:
https://developer.wordpress.org/reference/functions/add_shortcode/

2) In this PHP function:
a) get your custom number field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
b) format as what you want:
hidden link

#2548701

Hi there,

Many thanks for your help.

I'm very sorry, but I'm not a PHP developer at all and I'm not able to achieve with my poor programing skills. So, I need a more detailed step by step guideline, with a view to achieve.

Can you do that for me, or give me where to find it (tuto or video...)

Regards.

Jean

#2549141

Here is a demo site:
Login URL:
hidden link

Detail steps:
1) Create a custom number field "test-n-f"
hidden link

2) Dashboard-> Toolset-> Settings-> Custom code
Add a new item, with below codes:

add_shortcode('currency_format', function($atts, $content){
	$res = do_shortcode($content);
  	$res = number_format($res, 2, ',', ' ');
  	return $res;
});

3) Create a post, display above custom shortcode like this:
[currency_format][types field='test-n-f' output='raw'][/types][/currency_format]

It works fine in frontend:
hidden link

For your reference.

#2551573

My issue is resolved. Thank you!