Fix: dec=”2″ dropping last number if 0
-
Been using this plugin for a few years now and find it quite handy for some situations. Somewhere along the line it started dropping the last decimal on me when it ends in zero regardless of what you set the dec= attribute to.
Thinking it may of been around the time I upgraded to php8.
My hack of a fix, not sure if it is the best way or how you should properly do it but it works for me if anyone else uses this and starts noticing the same issue.
I tweaked the output of the last elseif for when no int is set. Also be sure to remove any int settings from your shortcodes.
The 4th last line in calculate-values-shortcodes.php:
Originally:
return $result;
Change to:
return number_format($result,2,'.',',');
Now it forces the second decimal place, yay! Change your decimal and comma settings to your liking but the above is for 0,000.00 format.
Duct tape kind of fix.
Cheers,
Ryan
- The topic ‘Fix: dec=”2″ dropping last number if 0’ is closed to new replies.