From fb52c4bffca4ea768e90f5aab9ecd17c71cfa127 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Thu, 22 Aug 2019 18:57:35 +0530 Subject: [PATCH] WIP: Frontend resolution of catalog rule pricing --- packages/Webkul/Discount/src/Helpers/Catalog/Apply.php | 10 +++++----- packages/Webkul/Product/src/Helpers/Price.php | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php index b9658f9c4..855d8d065 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php @@ -13,7 +13,7 @@ use Webkul\Discount\Helpers\Catalog\Sale; * Apply - Applies catalog rule to products intended in the rules * * @author Prashant Singh @prashant-webkul - * @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com) + * @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com) */ class Apply extends Sale { @@ -119,10 +119,8 @@ class Apply extends Sale $this->setSale($rule, $productIDs); } } - - // dd($result, 'processing done'); } else { - // handle the deceased rules here + // handle the deceased rules here or call the declutter handler over here // dd($this->deceased); } } @@ -196,6 +194,8 @@ class Apply extends Sale $winnerRuleId = $this->breakTie($previousRuleID, $newRuleID, $product); + $discountAmount = $this->getDiscountAmount($product, $rule); + $data = [ 'catalog_rule_id' => $rule->id, 'starts_from' => $rule->starts_from, @@ -204,7 +204,7 @@ class Apply extends Sale 'channel_id' => $channelId, 'product_id' => $productID, 'action_code' => $rule->action_code, - 'action_amount' => $discountPrice + 'action_amount' => $discountAmount ]; if ($rule->id == $winnerRuleId) { diff --git a/packages/Webkul/Product/src/Helpers/Price.php b/packages/Webkul/Product/src/Helpers/Price.php index bfdb08c51..0e63dece6 100755 --- a/packages/Webkul/Product/src/Helpers/Price.php +++ b/packages/Webkul/Product/src/Helpers/Price.php @@ -71,7 +71,8 @@ class Price extends AbstractProduct } $qb = ProductFlat::join('products', 'product_flat.product_id', '=', 'products.id') - ->where('products.parent_id', $productId); + ->join('catalog_rule_products', 'catalog_rule_products.product_id', '=', 'products.id') + ->where('products.parent_id', $productId); $result = $qb ->distinct()