Round prices up to nearest 5 after conversion in oscommerce
A conversion question relating to prices in oscommerce:
I am needing for a custom currency conversion to round the USD prices up to the nearest 5$ to avoid prices being displayed at silly prices such as $263.
I am trying to convert to an int and round the following line :
$curr->display_pric开发者_开发知识库e($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']));
( as for some reason the price is displayed as a string, im guessing to include the currency sign)
However not having much luck.
Does anybody know where the root conversion takes place as it might be easier for me to round() or ceil() from there when it is a raw integer
Or any other ideas of how I can round the conversion?
Thanks for any help
Rhys Thomas
For rounding floating points to a nearest number I use a method like this. This might give some clue:
// Rounds X to the nearest Y
private double round(double x, double y)
{
return Math.Floor(x / y + 0.5) * y;
}
精彩评论