Commit b26c5875 authored by Thomas Bilk's avatar Thomas Bilk

some minor changes with regards to new price conditions

parent 3ac51f09
...@@ -542,20 +542,21 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{ ...@@ -542,20 +542,21 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{
public function totalOnlyConditions($type = null) { public function totalOnlyConditions($type = null) {
$subTotal = $this->subTotal(); $subTotal = $this->subTotal();
$cond = $type $conditions = $type
? $this->getConditionsByType($type) ? $this->getConditionsByType($type)
: $this->getConditions() : $this->getConditions();
;
$itemConditionTotal = $this->totalItemsOnlyConditions($type); $itemConditionTotal = $this->totalItemsOnlyConditions($type);
if ($cond->isEmpty()) if ($conditions->isEmpty()) {
return $itemConditionTotal; return $itemConditionTotal;
}
$condTotal = $cond->sum(function ($cond) use ($subTotal) { $condTotal = $conditions
/** @var Condition $cond */ ->filter(function (Condition $cond) {
return $cond->getTarget() === Condition::TARGET_CART return $cond->getTarget() === Condition::TARGET_CART;
? $cond->applyCondition($subTotal) })
: 0; ->sum(function (Condition $cond) use ($subTotal) {
}); return $cond->applyCondition($subTotal);
});
return $itemConditionTotal + $condTotal; return $itemConditionTotal + $condTotal;
} }
...@@ -577,6 +578,9 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{ ...@@ -577,6 +578,9 @@ class Cart implements Jsonable, \JsonSerializable, Arrayable{
*/ */
public function totalConditionsList($withItemConditions = true) { public function totalConditionsList($withItemConditions = true) {
return $this->getConditions($withItemConditions) return $this->getConditions($withItemConditions)
->reject(function (Condition $c) {
return $c->getTarget() == Condition::TARGET_PRICE;
})
->map(function (Condition $i) { ->map(function (Condition $i) {
return $i->getType(); return $i->getType();
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment