In searching your support site for a way to format the price field using the familiar US Dollar format that uses a dollar sign, commas and decimal points, I see vague references to ideas such as wpcf_fields_slug_price_value_display. Where would I find a list shortcodes, functions or CSS that would make this possible?
It seems that people have asked this question for several years, but you have never incorporated a money format field as part of the regular system? Why not?
Why do we still have to post extra code to functions.php to attempt something as simple as this?
Thank you.
Thank you. That worked, except I had to reverse the placement of the decimal and comma values.
add_filter('wpcf_fields_slug_price_value_display', 'my_price_format');
function my_price_format($value) {
$value = "$ ".number_format($value, 2, '.', ',');
return $value;
}
PHP manual says:
This function accepts either one, two, or four parameters (not three):
If only one parameter is given, number will be formatted without decimals, but with a comma (",") between every group of thousands.
If two parameters are given, number will be formatted with decimals decimals with a dot (".") in front, and a comma (",") between every group of thousands.
If all four parameters are given, number will be formatted with decimals decimals, dec_point instead of a dot (".") before the decimals and thousands_sep instead of a comma (",") between every group of thousands.
And according to W3Resource.com this will also work.