This commit is contained in:
Prashant Singh 2019-08-22 15:59:54 +05:30
parent ee4c4c43cb
commit 5b33eb4a56
1 changed files with 20 additions and 1 deletions

View File

@ -198,6 +198,8 @@ abstract class Discount
if ($alreadyApplied->count() && $alreadyApplied->first()->cart_rule->id == $rule->id) {
if ($this->validateRule($alreadyApplied->first()->cart_rule)) {
$this->reassess($alreadyApplied->first()->cart_rule, $cart);
return false;
} else {
$this->clearDiscount();
@ -255,6 +257,20 @@ abstract class Discount
}
}
/**
* To reassess the discount in case no. of items gets changed
*
* @return Void
*/
public function reassess($rule)
{
$rule->impact = $this->calculateImpact($rule);
$this->updateCartItemAndCart($rule);
return;
}
/**
* To return cart rule which has the max impact
*
@ -647,8 +663,11 @@ abstract class Discount
$result = $this->validateRule($alreadyAppliedRule);
if (! $result)
if (! $result) {
$this->clearDiscount();
} else {
$this->reassess($alreadyAppliedRule);
}
}
}