diff --git a/CHANGELOG.md b/CHANGELOG.md index 1308f94..20dba90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ### Fixed - Fixed a missing auth header during customer token generation - Fixed the config reader to return the correct value when falsy values are configured (e.g. 0, 'false') +- Fixed compatibility to PHP 8.0 ### Added - Allowed manual and individual adding of positions which are not related to an article diff --git a/src/Components/Transformer/LineItemTransformer.php b/src/Components/Transformer/LineItemTransformer.php index bd4fb06..e1c6932 100644 --- a/src/Components/Transformer/LineItemTransformer.php +++ b/src/Components/Transformer/LineItemTransformer.php @@ -292,10 +292,14 @@ public function createShippingLineItem($shippingCostsWithTax, $shippingCostsNet, */ public function getUnitPriceWithTax(array $lineItem): float { - $netPriceIsShown = isset($lineItem['amountWithTax']) ? true : false; + $netPrice = $lineItem['amountWithTax'] ?? null; - if ($netPriceIsShown) { - return round(str_replace(',', '.', $lineItem['amountWithTax']) / $lineItem['quantity'], 2); + if ($netPrice !== null) { + if (is_string($netPrice)) { + $netPrice = (float) str_replace(',', '.', $lineItem['amountWithTax']); + } + + return round($netPrice / $lineItem['quantity'], 2); } return (float) $lineItem['priceNumeric'];