From f005a9253482d3d91bea97d29e8d840c9b2ece4e Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 28 Jan 2021 16:12:35 +0530 Subject: [PATCH] Issue #4523 --- .../Webkul/Product/src/Type/Configurable.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index c0b27c972..8722d97e7 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -96,7 +96,7 @@ class Configurable extends AbstractType { $product = parent::update($data, $id, $attribute); $route = request()->route() ? request()->route()->getName() : ''; - + if ($route != 'admin.catalog.products.massupdate') { $previousVariantIds = $product->variants->pluck('id'); @@ -355,7 +355,7 @@ class Configurable extends AbstractType */ public function getMinimalPrice($qty = null) { - $minPrices = []; + $minPrices = $rulePrices = []; /* method is calling many time so using variable */ $tablePrefix = DB::getTablePrefix(); @@ -373,11 +373,19 @@ class Configurable extends AbstractType $minPrices[] = $price->min_price; } + foreach ($this->product->variants as $variant) { + $rulePrice = app('Webkul\CatalogRule\Helpers\CatalogRuleProductPrice')->getRulePrice($variant); + + if ($rulePrice) { + $rulePrices[] = $rulePrice->price; + } + } + if (empty($minPrices)) { return 0; } - return min($minPrices); + return min(array_merge($minPrices, $rulePrices)); } /** @@ -540,7 +548,7 @@ class Configurable extends AbstractType $product = $item->child->product; } else { $product = $item->product; - } + } } }