Skip to content

Commit

Permalink
Fixed discount calculation for empty carts
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Jan 15, 2025
1 parent 8becc4b commit 271c186
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions classes/pricing/concerns/ApplyDiscounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 271c186

Please sign in to comment.