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{
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();
})
......
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