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:
parent
c2320410ab
commit
e404465cc7
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue