Merge pull request #4391 from rahulshukla-webkul/development
#3638 fixed
This commit is contained in:
commit
3c49cd9fff
|
|
@ -179,7 +179,7 @@ class CartRule
|
|||
/** @var \Webkul\CartRule\Models\CartRule $rule */
|
||||
// Laravel relation is used instead of repository for performance
|
||||
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
|
||||
$coupon = $rule->cart_rule_coupon->where('code', $cart->coupon_code)->first();
|
||||
$coupon = $rule->cart_rule_coupon()->where('code', $cart->coupon_code)->first();
|
||||
|
||||
if ($coupon && $coupon->code === $cart->coupon_code) {
|
||||
if ($coupon->usage_limit && $coupon->times_used >= $coupon->usage_limit) {
|
||||
|
|
@ -275,25 +275,19 @@ class CartRule
|
|||
break;
|
||||
|
||||
case 'cart_fixed':
|
||||
// if ($this->itemTotals[$rule->id]['total_items'] <= 1) {
|
||||
// $discountAmount = core()->convertPrice($rule->discount_amount);
|
||||
if ($this->itemTotals[$rule->id]['total_items'] <= 1) {
|
||||
$discountAmount = core()->convertPrice($rule->discount_amount);
|
||||
|
||||
// $baseDiscountAmount = min($item->base_price * $quantity, $rule->discount_amount);
|
||||
// } else {
|
||||
// $discountRate = $item->base_price * $quantity / $this->itemTotals[$rule->id]['base_total_price'];
|
||||
$baseDiscountAmount = min($item->base_price * $quantity, $rule->discount_amount);
|
||||
} else {
|
||||
$discountRate = $item->base_price * $quantity / $this->itemTotals[$rule->id]['base_total_price'];
|
||||
|
||||
// $maxDiscount = $rule->discount_amount * $discountRate;
|
||||
$maxDiscount = $rule->discount_amount * $discountRate;
|
||||
|
||||
// $discountAmount = core()->convertPrice($maxDiscount);
|
||||
$discountAmount = core()->convertPrice($maxDiscount);
|
||||
|
||||
// $baseDiscountAmount = min($item->base_price * $quantity, $maxDiscount);
|
||||
// }
|
||||
|
||||
$discountAmount = core()->convertPrice($rule->discount_amount);
|
||||
|
||||
$baseDiscountAmount = min($item->base_price * $quantity, $rule->discount_amount);
|
||||
|
||||
$discountAmount = min($item->price * $quantity, $discountAmount);
|
||||
$baseDiscountAmount = min($item->base_price * $quantity, $maxDiscount);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -537,7 +531,7 @@ class CartRule
|
|||
}
|
||||
|
||||
$coupons = $this->cartRuleCouponRepository->where(['code' => $cart->coupon_code])->get();
|
||||
|
||||
|
||||
foreach ($coupons as $coupon) {
|
||||
if (in_array($coupon->cart_rule_id, explode(',', $cart->applied_cart_rule_ids))) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue