Skip to content

Commit d1cba67

Browse files
committed
ACP2E-3463: Invalid discount calculation with priority
1 parent 01609e7 commit d1cba67

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

app/code/Magento/SalesRule/Helper/CartFixedDiscount.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -137,9 +137,9 @@ public function getDiscountedAmountProportionally(
137137
): float {
138138
$baseItemPriceTotal = $baseItemPrice * $qty - $baseItemDiscountAmount;
139139
$ratio = $baseRuleTotalsDiscount != 0 ? $baseItemPriceTotal / $baseRuleTotalsDiscount : 0;
140-
$discountAmount = $this->deltaPriceRound->round($ruleDiscount * $ratio, $discountType);
140+
$ratio = min($ratio, 1);
141141

142-
return $discountAmount;
142+
return $this->deltaPriceRound->round($ruleDiscount * $ratio, $discountType);
143143
}
144144

145145
/**

app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ public function calculate($rule, $item, $qty)
133133
$qty,
134134
$baseItemPrice,
135135
$baseItemDiscountAmount,
136-
//$baseRuleTotals - $ruleTotals['base_items_discount_amount'],
137-
//$baseRuleTotals - $address->getBaseDiscountAmount(),
138-
$baseRuleTotals,
136+
$baseRuleTotals - $address->getBaseDiscountAmount(),
139137
$discountType
140138
);
141139
}

0 commit comments

Comments
 (0)