Skip Navigation

[Resolved] We need to display numeric fields with the . character for numeric separator

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 3 voices.

Last updated by Franco Calcagni 7 years ago.

Assisted by: Minesh.

Author
Posts
#589195
capture.png

Tell us what you are trying to do? We need to diaplay some numeric fields as follow 1.200.000 instead of 1200000

What is the link to your site? hidden link

#589346

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Types offers the filter: wpcf_fields_slug_{your_custom_field_slug}_value_display
Where:
- Replace {your_custom_field_slug} with your custom field slug.

So, for example if you have custom field namely price, then the filter should be as given under. Please try to add following code to your current theme's functions.php file:

add_filter('wpcf_fields_slug_price_value_display', 'my_price_format');
function my_price_format($value) {
$returnValue = number_format($value, 0, '.', '.');
return $returnValue ;
}

Where - "price" is your custom field slug.

#589396

Thanks for your reply, How can we change the function you sent us if the price now have the following format

16200.000 (so it has already the last . but misses the . between the 16 and 200 value?

#589402

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - number format allows to add thousand separator so we can omit it.

You may try to check following links and try to adjust your format as per your need using number_format() or money_format() functions:
=> hidden link
=> hidden link

#589424

y.S

Try this:

add_filter('wpcf_fields_slug_price_value_display', 'my_price_format');
function my_price_format($value) {
$returnValue = number_format($value, 0, '.', '.');

if ( strlen($returnValue) > 7 )
    $returnValue = substr($returnValue, 0, -7) . '.' . substr($returnValue, -7);

return $returnValue ;
}
#590890

solved, thanks!