Skip to content

Commit

Permalink
Fix total-value package functions enforcing integer values
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Oct 3, 2024
1 parent deec3ba commit 0301c05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/carriers/USPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
8 changes: 4 additions & 4 deletions src/models/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 0301c05

Please sign in to comment.