Skip to content

Commit 648ea36

Browse files
authored
ENGCOM-3464: Floating point overflows in checkout totals fixed #18185
2 parents ae96f4f + 4602008 commit 648ea36

File tree

1 file changed

+7
-0
lines changed
  • app/code/Magento/Quote/Model/Quote/Address

1 file changed

+7
-0
lines changed

app/code/Magento/Quote/Model/Quote/Address/Total.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Quote\Model\Quote\Address;
77

88
/**
9+
* Class Total
10+
*
911
* @method string getCode()
1012
*
1113
* @api
@@ -54,6 +56,8 @@ public function __construct(
5456
*/
5557
public function setTotalAmount($code, $amount)
5658
{
59+
$amount = is_float($amount) ? round($amount, 4) : $amount;
60+
5761
$this->totalAmounts[$code] = $amount;
5862
if ($code != 'subtotal') {
5963
$code = $code . '_amount';
@@ -72,6 +76,8 @@ public function setTotalAmount($code, $amount)
7276
*/
7377
public function setBaseTotalAmount($code, $amount)
7478
{
79+
$amount = is_float($amount) ? round($amount, 4) : $amount;
80+
7581
$this->baseTotalAmounts[$code] = $amount;
7682
if ($code != 'subtotal') {
7783
$code = $code . '_amount';
@@ -167,6 +173,7 @@ public function getAllBaseTotalAmounts()
167173

168174
/**
169175
* Set the full info, which is used to capture tax related information.
176+
*
170177
* If a string is used, it is assumed to be serialized.
171178
*
172179
* @param array|string $info

0 commit comments

Comments
 (0)