Merge pull request #1377 from prashant-webkul/development
Current discount actions are normalized again with safe conditions im…
This commit is contained in:
commit
04636229d8
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue