Merge pull request #1767 from prashant-webkul/bugs_patch_1

Fixed issues related to discount calculations
This commit is contained in:
Jitendra Singh 2019-11-14 17:09:57 +05:30 committed by GitHub
commit 27214ed088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -32,7 +32,15 @@ class PercentOfProduct extends Action
if ($applicability) {
$eligibleItems = $this->getEligibleItems();
$applicableDiscount = \Cart::getCart()->base_sub_total * ($rule->disc_amount / 100);
$applicableDiscount = function () use ($eligibleItems) {
$total = 0;
foreach ($eligibleItems as $item) {
$total = $total + $item->base_total;
}
return $total;
};
foreach ($eligibleItems as $item) {
$report = array();
@ -40,7 +48,7 @@ class PercentOfProduct extends Action
$report['item_id'] = $item->id;
$report['child_items'] = collect();
$perItemDiscount = $applicableDiscount / $eligibleItems->count();
$perItemDiscount = $applicableDiscount() * ($rule->disc_amount / 100) / $eligibleItems->count();
$itemPrice = $item->base_price;

View File

@ -433,8 +433,12 @@ abstract class Discount
foreach ($productIDs as $productID) {
foreach ($cart->items as $item) {
if ($item->product_id == $productID)
$partialMatch = 1;
$childrens = $item->children;
foreach ($childrens as $children) {
if ($children->product_id == $productID)
$partialMatch = 1;
}
}
}
}