Skip to content

Commit 7635d42

Browse files
committed
MAGETWO-51868: [Github] USPS shipping weight calculation rounds ounces to whole number
- Added private static variable
1 parent a92e203 commit 7635d42

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
6767
*/
6868
protected $_code = self::CODE;
6969

70+
/**
71+
* Weight precision
72+
*
73+
* @var int
74+
*/
75+
private static $weightPrecision = 10;
76+
7077
/**
7178
* Rate request data
7279
*
@@ -324,7 +331,7 @@ public function setRequest(\Magento\Quote\Model\Quote\Address\RateRequest $reque
324331

325332
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
326333
$r->setWeightPounds(floor($weight));
327-
$r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, 10));
334+
$r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, self::$weightPrecision));
328335
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
329336
$r->setFreeMethodWeight($request->getFreeMethodWeight());
330337
}
@@ -371,7 +378,7 @@ protected function _setFreeMethodRequest($freeMethod)
371378

372379
$weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight());
373380
$r->setWeightPounds(floor($weight));
374-
$r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, 10));
381+
$r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, self::$weightPrecision));
375382
$r->setService($freeMethod);
376383
}
377384

0 commit comments

Comments
 (0)