Merge pull request #1377 from prashant-webkul/development

Current discount actions are normalized again with safe conditions im…
This commit is contained in:
Jitendra Singh 2019-08-31 18:20:26 +05:30 committed by GitHub
commit 04636229d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 14 deletions

View File

@ -36,20 +36,24 @@ class FixedAmount extends Action
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
if ($rule->disc_amount > $itemPrice) {
$discount = round($rule->disc_amount * $discQuantity, 4);
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $itemPrice;
$discount = $rule->disc_amount;
}
} else if ($itemQuantity < $discQuantity) {
if ($rule->disc_amount > $itemPrice) {
$discount = round($rule->disc_amount * $itemQuantity, 4);
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $itemPrice;
$discount = $rule->disc_amount;
}
}
} else {
$discount = $rule->disc_amount;
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $rule->disc_amount;
}
}
if ($itemProductId == $productID) {
@ -78,20 +82,24 @@ class FixedAmount extends Action
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
if ($rule->disc_amount > $itemPrice) {
$discount = round($rule->disc_amount * $discQuantity, 4);
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $itemPrice;
$discount = $rule->disc_amount;
}
} else if ($itemQuantity < $discQuantity) {
if ($rule->disc_amount > $itemPrice) {
$discount = round($rule->disc_amount * $itemQuantity, 4);
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $itemPrice;
$discount = $rule->disc_amount;
}
}
} else {
$discount = $rule->disc_amount;
if ($rule->disc_amount >= $itemPrice) {
$discount = round($itemPrice * $discQuantity, 4);
} else {
$discount = $rule->disc_amount;
}
}
$totalDiscount = $totalDiscount + $discount;

View File

@ -53,11 +53,23 @@ class PercentOfProduct extends Action
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
} else if ($itemQuantity < $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $itemQuantity;
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
}
} else {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
}
if ($itemProductId == $productID) {
@ -87,11 +99,23 @@ class PercentOfProduct extends Action
if ($discQuantity > 1) {
if ($itemQuantity >= $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $discQuantity;
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
} else if ($itemQuantity < $discQuantity) {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4) * $itemQuantity;
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
}
} else {
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
}
$totalDiscount = $totalDiscount + $discount;

View File

@ -47,6 +47,10 @@ class WholeCartToPercent extends Action
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
if ($discount >= $itemPrice) {
$discount = $itemPrice;
}
$totalDiscount = $totalDiscount + $discount;
if ($item->product_id == $productID) {
@ -76,6 +80,10 @@ class WholeCartToPercent extends Action
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
if ($discount > $itemPrice) {
$discount = $itemPrice;
}
$totalDiscount = $totalDiscount + $discount;
$report = array();