...
 
Commits (2)
......@@ -6,7 +6,11 @@
"authors": [
{
"name": "Thorsten Buss",
"email": "thorsten.buss@buss-networks.de"
"email": "thorsten@buss-labs.de"
},
{
"name": "Thomas Bilk",
"email": "thomas@buss-labs.de"
}
],
"require": {
......
......@@ -542,20 +542,21 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{
public function totalOnlyConditions($type = null) {
$subTotal = $this->subTotal();
$cond = $type
$conditions = $type
? $this->getConditionsByType($type)
: $this->getConditions()
;
: $this->getConditions();
$itemConditionTotal = $this->totalItemsOnlyConditions($type);
if ($cond->isEmpty())
if ($conditions->isEmpty()) {
return $itemConditionTotal;
}
$condTotal = $cond->sum(function ($cond) use ($subTotal) {
/** @var Condition $cond */
return $cond->getTarget() === Condition::TARGET_CART
? $cond->applyCondition($subTotal)
: 0;
});
$condTotal = $conditions
->filter(function (Condition $cond) {
return $cond->getTarget() === Condition::TARGET_CART;
})
->sum(function (Condition $cond) use ($subTotal) {
return $cond->applyCondition($subTotal);
});
return $itemConditionTotal + $condTotal;
}
......@@ -577,6 +578,9 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{
*/
public function totalConditionsList($withItemConditions = true) {
return $this->getConditions($withItemConditions)
->reject(function (Condition $c) {
return $c->getTarget() == Condition::TARGET_PRICE;
})
->map(function (Condition $i) {
return $i->getType();
})
......