开发者

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;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜