diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index a804bac3b9b..dda15f9d253 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -251,10 +251,13 @@ if (empty($reshook)) { $object->origin = $origin; $object->origin_id = $origin_id; $object->fk_project = GETPOSTINT('projectid'); - $object->weight = GETPOSTINT('weight') == '' ? "NULL" : GETPOSTINT('weight'); - $object->sizeH = GETPOSTINT('sizeH') == '' ? "NULL" : GETPOSTINT('sizeH'); - $object->sizeW = GETPOSTINT('sizeW') == '' ? "NULL" : GETPOSTINT('sizeW'); - $object->sizeS = GETPOSTINT('sizeS') == '' ? "NULL" : GETPOSTINT('sizeS'); + // Weight and box dimensions are physical measurements that frequently use + // decimals (1.6 kg, 0.25 m, ...), so they must be read as floats and not + // truncated to int (see issue #34069 for the shipping module). + $object->weight = GETPOST('weight', 'alpha') == '' ? "NULL" : GETPOSTFLOAT('weight'); + $object->sizeH = GETPOST('sizeH', 'alpha') == '' ? "NULL" : GETPOSTFLOAT('sizeH'); + $object->sizeW = GETPOST('sizeW', 'alpha') == '' ? "NULL" : GETPOSTFLOAT('sizeW'); + $object->sizeS = GETPOST('sizeS', 'alpha') == '' ? "NULL" : GETPOSTFLOAT('sizeS'); $object->size_units = GETPOSTINT('size_units'); $object->weight_units = GETPOSTINT('weight_units'); @@ -579,18 +582,18 @@ if (empty($reshook)) { $object->tracking_url = trim(GETPOST('tracking_url', 'restricthtml')); } if ($action == 'settrueWeight') { - $object->trueWeight = GETPOSTINT('trueWeight'); + $object->trueWeight = GETPOSTFLOAT('trueWeight'); $object->weight_units = GETPOSTINT('weight_units'); } if ($action == 'settrueWidth') { - $object->trueWidth = GETPOSTINT('trueWidth'); + $object->trueWidth = GETPOSTFLOAT('trueWidth'); } if ($action == 'settrueHeight') { - $object->trueHeight = GETPOSTINT('trueHeight'); + $object->trueHeight = GETPOSTFLOAT('trueHeight'); $object->size_units = GETPOSTINT('size_units'); } if ($action == 'settrueDepth') { - $object->trueDepth = GETPOSTINT('trueDepth'); + $object->trueDepth = GETPOSTFLOAT('trueDepth'); } if ($action == 'setshipping_method_id') { $object->shipping_method_id = GETPOSTINT('shipping_method_id'); @@ -1080,7 +1083,7 @@ if ($action == 'create') { print $langs->trans("Weight"); print '