Skip to content

Commit 3001450

Browse files
committed
AC-13855: Penny rounding error in catalog rule
Update roundPrice method to use the new way of rounding to fix php 8.4 rounding error
1 parent 1195dc3 commit 3001450

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

app/code/Magento/Directory/Model/PriceCurrency.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,10 @@ protected function getStore($scope = null)
152152
*/
153153
public function round($price)
154154
{
155-
// To fix rounding error in PHP 8.4
156-
if (version_compare(PHP_VERSION, '8.4', '>=')) {
157-
return round(
158-
floatval((string) $price),
159-
2
160-
);
161-
}
162-
return round((float) $price, 2);
155+
return round(
156+
floatval((string) $price), // To fix rounding error in PHP 8.4
157+
2
158+
);
163159
}
164160

165161
/**
@@ -171,6 +167,9 @@ public function round($price)
171167
*/
172168
public function roundPrice($price, $precision = self::DEFAULT_PRECISION)
173169
{
174-
return round((float) $price, $precision);
170+
return round(
171+
floatval((string) $price), // To fix rounding error in PHP 8.4
172+
$precision
173+
);
175174
}
176175
}

0 commit comments

Comments
 (0)