diff --git a/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php b/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php index 0b6fa3d1a..1edd39f15 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php +++ b/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php @@ -9,7 +9,7 @@ class AppointmentSlot extends Booking * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct * @return bool */ - public function haveSufficientQuantity($qty, $bookingProduct) + public function haveSufficientQuantity(int $qty, $bookingProduct): bool { return true; } diff --git a/packages/Webkul/BookingProduct/src/Type/Booking.php b/packages/Webkul/BookingProduct/src/Type/Booking.php index ea913a07a..7c31354de 100644 --- a/packages/Webkul/BookingProduct/src/Type/Booking.php +++ b/packages/Webkul/BookingProduct/src/Type/Booking.php @@ -158,7 +158,7 @@ class Booking extends Virtual * @param int $qty * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { return true; } diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index fc3682eca..1d4613d36 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -795,7 +795,13 @@ class Cart */ public function isItemsHaveSufficientQuantity(): bool { - foreach ($this->getCart()->items as $item) { + $cart = cart()->getCart(); + + if (! $cart) { + return false; + } + + foreach ($cart->items as $item) { if (! $this->isItemHaveQuantity($item)) { return false; } diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 86acea5a1..f092e9e04 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -261,11 +261,11 @@ class Product extends Model implements ProductContract } /** - * @param integer $qty + * @param int $qty * * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { return $this->getTypeInstance()->haveSufficientQuantity($qty); } diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php index 1e0517755..d2fb715aa 100644 --- a/packages/Webkul/Product/src/Models/ProductFlat.php +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -99,11 +99,11 @@ class ProductFlat extends Model implements ProductFlatContract } /** - * @param integer $qty + * @param int $qty * * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { return $this->product->haveSufficientQuantity($qty); } diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 89425156f..1229c1b6c 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -350,7 +350,7 @@ abstract class AbstractType * * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { return $this->haveSufficientQuantity; } @@ -555,7 +555,7 @@ abstract class AbstractType if ($haveSpecialPrice) { $this->product->special_price = min($this->product->special_price, $customerGroupPrice); } else { - $haveSpecialPrice = true; + $haveSpecialPrice = true; $this->product->special_price = $customerGroupPrice; } diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index db7f283da..716d6fe74 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -685,7 +685,15 @@ class Bundle extends AbstractType } foreach ($item->children as $childItem) { - $childItem->product->getTypeInstance()->validateCartItem($childItem); + $childResult = $childItem->product->getTypeInstance()->validateCartItem($childItem); + + if ($childResult->isItemInactive()) { + $result->itemIsInactive(); + } + + if ($childResult->isCartDirty()) { + $result->cartIsDirty(); + } $price += $childItem->base_price * $childItem->quantity; } diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index bd44e44aa..727b72fe3 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -592,7 +592,7 @@ class Configurable extends AbstractType * @param int $qty * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { $backorders = core()->getConfigData('catalog.inventory.stock_options.backorders'); diff --git a/packages/Webkul/Product/src/Type/Simple.php b/packages/Webkul/Product/src/Type/Simple.php index 2c0a90e5a..6b5659108 100644 --- a/packages/Webkul/Product/src/Type/Simple.php +++ b/packages/Webkul/Product/src/Type/Simple.php @@ -53,12 +53,12 @@ class Simple extends AbstractType * @param int $qty * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { $backorders = core()->getConfigData('catalog.inventory.stock_options.backorders'); $backorders = ! is_null ($backorders) ? $backorders : false; - + return $qty <= $this->totalQuantity() ? true : $backorders; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/Virtual.php b/packages/Webkul/Product/src/Type/Virtual.php index 6f19a8941..ede642cb0 100644 --- a/packages/Webkul/Product/src/Type/Virtual.php +++ b/packages/Webkul/Product/src/Type/Virtual.php @@ -13,7 +13,7 @@ class Virtual extends AbstractType /** * These blade files will be included in product edit page - * + * * @var array */ protected $additionalViews = [ @@ -60,7 +60,7 @@ class Virtual extends AbstractType * @param int $qty * @return bool */ - public function haveSufficientQuantity($qty) + public function haveSufficientQuantity(int $qty): bool { return $qty <= $this->totalQuantity() ? true : false; }