This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
How to round the price
« on: March 21, 2018, 02:55:45 PM »
Hello,

I would like to round the prices in a way to end up always with a trailing zero.
For example the price of 3.04 to be rounded to 3.00

Some more examples:

4.45 to become 4.50
7.75 to become 7.70
5.81 to become 5.80

There must be a function which is doing calculation on 5% discount which I can not seem to find it.
functions.php is almost 3k lines.


Any guidance will be appreciated.


Thanks

*

MB Themes

Re: How to round the price
« Reply #1 on: March 21, 2018, 02:58:15 PM »
Try to look on function osp_format_price
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Locan

  • ****
  • 166 posts
Re: How to round the price
« Reply #2 on: March 21, 2018, 03:18:23 PM »
@Lyubomir Minchev
you can change it in plugin admin panel

Marked as best answer by frosticek on March 22, 2018, 08:19:28 AM
Re: How to round the price
« Reply #3 on: March 21, 2018, 03:22:05 PM »
Thank you guys for your quick responses !

I managed to round the price by modifying the function "osp_format_price". On 385 line in functions.php I added

Code: [Select]

$rprice = round((float)$price, 1, PHP_ROUND_HALF_UP);
$price = number_format($rprice, $decimals, $decimal_symbol, $thousands);

Here comes the marketing version :)

Code: [Select]
$rprice = round((float)$price, 1, PHP_ROUND_HALF_UP) - 0.01;
$price = number_format($rprice, $decimals, $decimal_symbol, $thousands);


Cheers!