From 67acbc8b993d6f067b88d46cd032825388271f1c Mon Sep 17 00:00:00 2001 From: Jaseel P V Date: Sun, 11 Oct 2020 13:46:04 +0530 Subject: [PATCH 1/2] Fixed customer group price discount issue --- .../Webkul/Product/src/Type/AbstractType.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 217df53ea..0b3e5a7a8 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -659,16 +659,20 @@ abstract class AbstractType continue; } - if ($price->value < $lastPrice) { - if ($price->value_type == 'discount') { - $lastPrice = $product->price - ($product->price * $price->value) / 100; - } else { - $lastPrice = $price->value; - } + if ($price->value_type == 'discount') { + $lastPrice = $product->price - ($product->price * $price->value) / 100; $lastQty = $price->qty; $lastCustomerGroupId = $price->customer_group_id; + } else { + if ($price->value < $lastPrice) { + $lastPrice = $price->value; + + $lastQty = $price->qty; + + $lastCustomerGroupId = $price->customer_group_id; + } } } From b96e45a8e189b3bd5bdeee289180f80bbd4a076c Mon Sep 17 00:00:00 2001 From: Jaseel P V Date: Tue, 13 Oct 2020 22:37:02 +0530 Subject: [PATCH 2/2] Added checks for discount and flat case --- packages/Webkul/Product/src/Type/AbstractType.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 0b3e5a7a8..be75cb2e5 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -660,13 +660,15 @@ abstract class AbstractType } if ($price->value_type == 'discount') { - $lastPrice = $product->price - ($product->price * $price->value) / 100; + if ($price->value >= 0 && $price->value <= 100) { + $lastPrice = $product->price - ($product->price * $price->value) / 100; - $lastQty = $price->qty; + $lastQty = $price->qty; - $lastCustomerGroupId = $price->customer_group_id; + $lastCustomerGroupId = $price->customer_group_id; + } } else { - if ($price->value < $lastPrice) { + if ($price->value >= 0 && $price->value < $lastPrice) { $lastPrice = $price->value; $lastQty = $price->qty;