From 271c186910640a0461b8197e1aae92c8dc2eeffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCndig?= Date: Wed, 15 Jan 2025 08:24:20 +0100 Subject: [PATCH] Fixed discount calculation for empty carts --- classes/pricing/concerns/ApplyDiscounts.php | 20 ++++++++++---------- updates/version.yaml | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/classes/pricing/concerns/ApplyDiscounts.php b/classes/pricing/concerns/ApplyDiscounts.php index f8ed3b442..8bf51d7a6 100644 --- a/classes/pricing/concerns/ApplyDiscounts.php +++ b/classes/pricing/concerns/ApplyDiscounts.php @@ -66,16 +66,16 @@ public function applyDiscounts() ); continue; - } - - $value = $amount->value(); - $values = $value->allocate(...$products); - for ($i = 0; $i < count($values); $i++) { - $this->map['products'][$i]->addDiscount( - $values[$i]->getMinorAmount()->toInt(), - false, - false - ); + } else if (count($products) > 1) { + $value = $amount->value(); + $values = $value->allocate(...$products); + for ($i = 0; $i < count($values); $i++) { + $this->map['products'][$i]->addDiscount( + $values[$i]->getMinorAmount()->toInt(), + false, + false + ); + } } } elseif ($amount instanceof FactorValue) { foreach ($this->map['products'] as $product) { diff --git a/updates/version.yaml b/updates/version.yaml index cd140b874..cf4536a57 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -633,3 +633,5 @@ v3.5.15: - 'Fixed category-specific manual sort orders' v3.5.16: - 'Fixed category-specific manual sort orders' +v3.5.17: + - 'Fixed discount calculation for empty Carts'