Merge pull request #1337 from prashant-webkul/development

Cart rule action PercentOfProduct max discount quantity fixes
This commit is contained in:
Jitendra Singh 2019-08-21 17:51:57 +05:30 committed by GitHub
commit 828a76a5b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 2 deletions

View File

@ -45,7 +45,21 @@ class PercentOfProduct extends Action
$itemProductId = $item->product_id;
}
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
$itemQuantity = $item->quantity;
$discQuantity = $rule->disc_quantity;
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
} else if ($itemQuantity < $discQuantity) {
$discQuantity = $discQuantity - $itemQuantity;
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
}
} else {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
}
if ($itemProductId == $productID) {
$totalDiscount = $totalDiscount + $discount;
@ -73,7 +87,21 @@ class PercentOfProduct extends Action
$itemProductId = $item->product_id;
}
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
$itemQuantity = $item->quantity;
$discQuantity = $rule->disc_quantity;
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
} else if ($itemQuantity < $discQuantity) {
$discQuantity = $discQuantity - $itemQuantity;
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
}
} else {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
}
$totalDiscount = $totalDiscount + $discount;