Forums / Setting Up Specials and SaleMaker / Sale Price: Round off to nearest 5 cents

Sale Price: Round off to nearest 5 cents

Started by cocolala on 4 Nov 2010, 1:29 PM · Views: 6,052

Results 1 to 3 of 3
4 Nov 2010, 1:29 PM
#1
cocolala avatar

cocolala

New Zenner

Join Date:
Jan 2010
Posts:
31
Plugin Contributions:
0

Sale Price: Round off to nearest 5 cents

// Wrapper function for round()
function zen_round($number, $precision) {
/// fix rounding error on GVs etc.
$number = round($number / 5, $precision) * 5;

return $number;
}

I have done the above to /includes/functions/functions_general.php
and it shows correctly in my website.

However, the invoice at admin>order is showing without rounding off.

I then add the above to the file myadmin/includes/functions/functions_general.php, the Price (inc) is showing with round off but Price (ex) is not.

FYI I don't set tax for my products.

Please advise.

2 Aug 2011, 9:46 PM
#2
drbyday avatar

drbyday

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Sale Price: Round off to nearest 5 cents

I managed to change these in the admin orders page by:

admin/orders.php

FIND

$order->products[$i]['final_price'] X 4 within the products listing table

and replace with

(round($order->products[$i]['final_price'] / 5) * 5)

In my case, I was looking to round to the nearest $5 increment so you can just change the calculation as needed.

I dont think this is modifying what is in the database. It seems to work though.

9 Jan 2012, 2:57 AM
#3
cocolala avatar

cocolala

New Zenner

Join Date:
Jan 2010
Posts:
31
Plugin Contributions:
0

Re: Sale Price: Round off to nearest 5 cents

drbyday:

I managed to change these in the admin orders page by:

admin/orders.php

FIND

$order->products[$i]['final_price'] X 4 within the products listing table

and replace with

(round($order->products[$i]['final_price'] / 5) * 5)

In my case, I was looking to round to the nearest $5 increment so you can just change the calculation as needed.

I dont think this is modifying what is in the database. It seems to work though.

I found many $order->products[$i]['final_price'] in the admin/order.php file. Do I need to replace all $order->products[$i]['final_price'] with (round($order->products[$i]['final_price'] / 5) * 5)
?