From 0301c05faf2c8d95500a7372081edc4d4160a781 Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Thu, 3 Oct 2024 14:13:52 +1000 Subject: [PATCH] Fix total-value package functions enforcing integer values --- src/carriers/USPS.php | 8 ++++---- src/models/Shipment.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/carriers/USPS.php b/src/carriers/USPS.php index eff6d1d..e917d62 100644 --- a/src/carriers/USPS.php +++ b/src/carriers/USPS.php @@ -160,10 +160,10 @@ public function getRates(Shipment $shipment): ?RateResponse 'mailingDate' => $shipDate, 'accountType' => 'EPS', 'accountNumber' => $this->accountNumber, - 'length' => max((float)$shipment->getTotalLength($this, 0), 0.1), - 'width' => max((float)$shipment->getTotalWidth($this, 0), 0.1), - 'height' => max((float)$shipment->getTotalHeight($this, 0), 0.1), - 'weight' => max((float)$shipment->getTotalWeight($this, 0), 0.1), + 'length' => max($shipment->getTotalLength($this, 2), 0.1), + 'width' => max($shipment->getTotalWidth($this, 2), 0.1), + 'height' => max($shipment->getTotalHeight($this, 2), 0.1), + 'weight' => max($shipment->getTotalWeight($this, 2), 0.1), ]; if (self::isDomestic($shipment->getTo()->getCountryCode())) { diff --git a/src/models/Shipment.php b/src/models/Shipment.php index 64ae6b1..ab79000 100644 --- a/src/models/Shipment.php +++ b/src/models/Shipment.php @@ -186,7 +186,7 @@ public function getPackagesForCarrier(CarrierInterface $carrier): array return $packages; } - public function getTotalWeight(CarrierInterface $carrier, int $decimals = 2): int + public function getTotalWeight(CarrierInterface $carrier, int $decimals = 2): int|float { $total = 0; @@ -197,7 +197,7 @@ public function getTotalWeight(CarrierInterface $carrier, int $decimals = 2): in return $total; } - public function getTotalWidth(CarrierInterface $carrier, int $decimals = 2, bool $stacked = true): int + public function getTotalWidth(CarrierInterface $carrier, int $decimals = 2, bool $stacked = true): int|float { $total = 0; @@ -213,7 +213,7 @@ public function getTotalWidth(CarrierInterface $carrier, int $decimals = 2, bool return $total; } - public function getTotalHeight(CarrierInterface $carrier, int $decimals = 2, bool $stacked = false): int + public function getTotalHeight(CarrierInterface $carrier, int $decimals = 2, bool $stacked = false): int|float { $total = 0; @@ -229,7 +229,7 @@ public function getTotalHeight(CarrierInterface $carrier, int $decimals = 2, boo return $total; } - public function getTotalLength(CarrierInterface $carrier, int $decimals = 2, bool $stacked = true): int + public function getTotalLength(CarrierInterface $carrier, int $decimals = 2, bool $stacked = true): int|float { $total = 0;