The below is taken from a completely standard OpenCart 1.4.4 install and the cart has a single 2kg item in it (so should be calculated as 2000 grams). The install is set to the default weight class of lbs (as I said, unchanged)
I added some debug code to the weight conversion function. When I load the cart, this is what I get.
This is the debug code in case you think it is to blame (just 5 additional echo lines to display the variables)
Code: Select all
public function convert($value, $from, $to) {
echo "Entering convert function<br />";
echo "Input Value: [" . $value ."]<br />";
echo "From: [" . $from . "]<br />";
echo "To: [" . $to . "]<br />";
if ($from == $to) {
return $value;
}
if (!isset($this->weights[strtolower($from)]) || !isset($this->weights[strtolower($to)])) {
return $value;
} else {
$from = $this->weights[strtolower($from)]['value'];
$to = $this->weights[strtolower($to)]['value'];
echo "Returning: [" . $value * ($from / $to) . "]<br /><br />";[/color]
return $value * ($from / $to);
}
}
Entering convert function
Input Value: [2]
From: [kg]
To: [lb]
Returning: [0.907194048807] <-- 2kg is ~4.4 lbs
But 0.9 Kilograms is approximately 2 lbs.. the from / to values are reversed????
I want to go _from_ my value of 2kg's to my value in lbs..
Entering convert function
Input Value: [0.907194048807]
From: [lb]
To: [g]
Returning: [0.002] <--.. um what? 0.9 lbs is 0.002 grams? am I reading this right?
0.9g = 0.002 lbs.. once again.. the from and to seem reversed?
I want to go _from_ my value of 0.9 pounds, _to_ my value in grams.
Why does this from/to not make sense?
Am I following this function correctly? are these the results I should be expecting? :|