Came across a weird rounding problem this morning.
Had an order of $3.98 and a line item of -$3.98 (from gift certificate module)
uc_order_get_total() returned 4.4408920985006E-16 instead of zero.
function uc_order_get_total($order, $products_only = FALSE) {
$total = 0;
if (is_array($order->products)) {
foreach ($order->products as $product) {
$total += $product->price * $product->qty;
}
}
if ($products_only) {
return $total;
}
$total += uc_line_items_calculate($order);
$result = module_invoke_all('order', 'total', $order, NULL);
foreach ($result as $key => $value) {
$total += $value;
}
return $total;
}
Been checking all values in db plus added a ton of drupal_set_message() to debug, but everything seems correct but the addition result... (no problems with uc_line_items_calculate())
Seems to me it's a PHP problem, had to insert this line before returning the total to fix it.
$total = round($total,2);
That being said, I'm not really fan of this fix and I'm a bit scared to overwrite it on next UC update. Any opinion/advice on this ?
Thanks

