Merge pull request #7024 from defrance/patch-14

Introduce weight conversion lb & oz
This commit is contained in:
Laurent Destailleur 2017-06-17 17:52:20 +02:00 committed by GitHub
commit b73228899a
4 changed files with 16 additions and 5 deletions

View File

@ -3097,9 +3097,18 @@ abstract class CommonObject
$trueWeightUnit=pow(10, $weightUnit); $trueWeightUnit=pow(10, $weightUnit);
$totalWeight += $weight * $qty * $trueWeightUnit; $totalWeight += $weight * $qty * $trueWeightUnit;
} }
else else {
{ if ($weight_units == 99) {
$totalWeight += $weight * $qty; // This may be wrong if we mix different units // conversion 1 Pound = 0.45359237 KG
$trueWeightUnit = 0.45359237;
$totalWeight += $weight * $qty * $trueWeightUnit;
} elseif ($weight_units == 98) {
// conversion 1 Ounce = 0.0283495 KG
$trueWeightUnit = 0.0283495;
$totalWeight += $weight * $qty * $trueWeightUnit;
}
else
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
} }
if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
{ {

View File

@ -441,7 +441,8 @@ function measuring_units_string($unit,$measuring_style='')
$measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg");
$measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg");
$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
} }
else if ($measuring_style == 'size') else if ($measuring_style == 'size')
{ {

View File

@ -124,6 +124,7 @@ WeightUnitkg=kg
WeightUnitg=g WeightUnitg=g
WeightUnitmg=mg WeightUnitmg=mg
WeightUnitpound=pound WeightUnitpound=pound
WeightUnitounce=ounce
Length=Length Length=Length
LengthUnitm=m LengthUnitm=m
LengthUnitdm=dm LengthUnitdm=dm

View File

@ -307,7 +307,7 @@ class FormProduct
$return=''; $return='';
$measuring_units=array(); $measuring_units=array();
if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,99=>1); if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1);
else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1);
else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1);
else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3 else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3