Skip Navigation

[Resolved] Remove .00 from the number fileds and adding , to them

This support ticket is created 4 years, 2 months 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by alexD-18 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1980767
remove decimal and 0 (2).jpg
remove decimal and 0.jpg
1 Shortcode puts them all to 0.jpg

Hello,

1 - I am using this guide - https://toolset.com/forums/topic/number-field-commas/
<p style="text-align: center;">£[ts_format_number][types field='price'][/types][/ts_format_number]</p>

It works when its on a single field - hidden link.
But when I add it to the category page it does the attached, can you please check this for me please.

2 - How do I removed the .00 from all numbers - they dont get imported with the .00 ? cant figure out where this is coming from.
see attached

#1980977

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alex,

Thank you for getting in touch. The issue here is being generated by the custom shortcode that you are using.


add_shortcode( 'ts_format_number', 'ts_format_number_func');
function ts_format_number_func( $atts, $content ) {
$int = (int) do_shortcode($content);
return number_format($int, 2);
}

In the code there is the number_format() function, change the 2 to 0 and this should remove the decimal places from the numbers.

Please let me know if this helps.

Thanks,
Shane

#1981093
2021-03-10 15_17_16-Edit WordPress Archives Block ‹ Saxe Coburg — WordPress – Mozilla Firefox.jpg

Thanks that worked perfectly for the single template. has removed the decimal and comma working perfectly.

But on the archive / category view - hidden link - the short code - <p style="text-align: center;">£[ts_format_number][types field='price'][/types][/ts_format_number]</p> - does not work and adds them all to 0 ?

why is it not working in the toolset category view, but works in the single view ?

thanks so much

#1981105

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alex,

Would you mind allowing me to have quick access to the site so that I can check what is happening here with this ?

I've enabled the private fields for your next response.

Thanks,
Shane

#1981139

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alex,

This should now be working.

Please let me know if everything is ok now.

Thanks,
Shane

#1981811

My issue is resolved now. Thank you!