From 1d9d19ac86d2f43b18a056bc09c7beb93390c2ce Mon Sep 17 00:00:00 2001 From: Devansh Bawari Date: Sat, 26 Nov 2022 13:35:02 +0530 Subject: [PATCH] Fixed For Configurable And Grouped Product --- .../Webkul/Product/src/Type/AbstractType.php | 6 +++++- packages/Webkul/Product/src/Type/Grouped.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 7bfdcf3e4..e52fdfc2e 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -497,6 +497,10 @@ abstract class AbstractType return false; } + if (! $this->haveSufficientQuantity(1)) { + return false; + } + return true; } @@ -1107,7 +1111,7 @@ abstract class AbstractType public function getCustomerGroupPricingOffers() { $offerLines = []; - + $customerGroup = $this->customerRepository->getCurrentGroup(); $customerGroupPrices = $this->product->customer_group_prices()->where(function ($query) use ($customerGroup) { diff --git a/packages/Webkul/Product/src/Type/Grouped.php b/packages/Webkul/Product/src/Type/Grouped.php index ca2cc7cb0..ec9d2e5b5 100644 --- a/packages/Webkul/Product/src/Type/Grouped.php +++ b/packages/Webkul/Product/src/Type/Grouped.php @@ -178,6 +178,23 @@ class Grouped extends AbstractType return false; } + /** + * Is product have sufficient quantity. + * + * @param int $qty + * @return bool + */ + public function haveSufficientQuantity(int $qty): bool + { + foreach ($this->product->grouped_products as $groupedProduct) { + if ($groupedProduct->associated_product->haveSufficientQuantity($qty)) { + return true; + } + } + + return false; + } + /** * Get product minimal price. *