Fixed an issue when only one cart rule was getting applied it was also returning db instance of cart rule with it

This commit is contained in:
Prashant Singh 2019-06-18 20:16:51 +05:30
parent c2320410ab
commit e404465cc7
2 changed files with 28 additions and 28 deletions

View File

@ -192,33 +192,6 @@ abstract class Discount
return true;
}
/**
* To find the least worth item in current cart instance
*
* @return array
*/
public function leastWorthItem()
{
$cart = Cart::getCart();
$leastValue = 999999999999;
$leastWorthItem = [];
foreach ($cart->items as $item) {
if ($item->price < $leastValue) {
$leastValue = $item->price;
$leastWorthItem = [
'id' => $item->id,
'price' => $item->price,
'base_price' => $item->base_price,
'quantity' => $item->quantity
];
}
}
return $leastWorthItem;
}
/**
* Update discount for least worth item
*/
@ -269,6 +242,33 @@ abstract class Discount
return true;
}
/**
* To find the least worth item in current cart instance
*
* @return array
*/
public function leastWorthItem()
{
$cart = Cart::getCart();
$leastValue = 999999999999;
$leastWorthItem = [];
foreach ($cart->items as $item) {
if ($item->price < $leastValue) {
$leastValue = $item->price;
$leastWorthItem = [
'id' => $item->id,
'price' => $item->price,
'base_price' => $item->base_price,
'quantity' => $item->quantity
];
}
}
return $leastWorthItem;
}
/**
* To find the max worth item in current cart instance
*

View File

@ -165,7 +165,7 @@ class NonCouponAbleRule extends Discount
} else {
$this->save(array_first($maxImpacts)['rule']);
return $maxImpacts;
return array_first($applicableRules)['impact'];
}
} else {
$this->save(array_first($prioritySorted)['rule']);