There are 2 functions in the weight library class.
one is for converting
one is for formatting
The conversion one should expect a numeric value input and return a numeric value.
The format function should expect a numeric value input and return a string value.
But the convert function adds number_formatting with the thousand_point, which in essence returns a string.
So if you want to convert a 1000 kg product into lbs, the convert will take "1000" and return "2,204".
The comma is then assumed to be a string so when the $cart->getWeight() function tries to += that returned value, it will only use the first "2" and truncate the rest. So 1000kg becomes 2lbs which is very wrong.
The convert function should only handle the numeric conversion. This also simplifies the function:
Code: Select all
public function convert($value, $from, $to) {
if ($from != $to) { $value=($value * (float)$this->rules[$from][$to]); }
return $value;
}