From e189a4fa80182c437ab6814dde2534631e2fd44c Mon Sep 17 00:00:00 2001 From: Matt April Date: Fri, 29 May 2020 12:26:13 -0400 Subject: [PATCH 1/5] Added haveSufficientQuantity() method for Bundle - checks that all required options have at least one product in stock. --- packages/Webkul/Product/src/Type/Bundle.php | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 6f797494d..119b792eb 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -652,4 +652,27 @@ class Bundle extends AbstractType return $options; } + + /** + * @param int $qty + * @return bool + */ + public function haveSufficientQuantity($qty) + { + # to consider a bundle in stock we need to check that at least one product from each required group is available for the given quantity + foreach ($this->product->bundle_options as $option) { + if($option->is_required) { + foreach ($option->bundle_option_products as $bundleOptionProduct) { + # as long as at least one product in the required group is available we can continue checking other groups + if($bundleOptionProduct->product->haveSufficientQuantity($bundleOptionProduct->qty * $qty)) { + continue 2; + } + } + # if any required option does not have any in-stock product option we will get here. + return false; + } + } + + return true; + } } \ No newline at end of file From 7cf6cdb9f008035978a6122162f823e800beb83b Mon Sep 17 00:00:00 2001 From: Matt April Date: Fri, 29 May 2020 12:30:32 -0400 Subject: [PATCH 2/5] Added product inventory levels to BundleOption - can be used to display out of stock bundle items in front end --- packages/Webkul/Product/src/Helpers/BundleOption.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/Webkul/Product/src/Helpers/BundleOption.php b/packages/Webkul/Product/src/Helpers/BundleOption.php index fcfca3148..b8a94a66d 100644 --- a/packages/Webkul/Product/src/Helpers/BundleOption.php +++ b/packages/Webkul/Product/src/Helpers/BundleOption.php @@ -35,6 +35,9 @@ class BundleOption extends AbstractProduct { $options = []; + # eager load all inventories for bundle options + $this->product->bundle_options->load('bundle_option_products.product.inventories'); + foreach ($this->product->bundle_options as $option) { $options[$option->id] = $this->getOptionItemData($option); } @@ -87,6 +90,8 @@ class BundleOption extends AbstractProduct 'product_id' => $bundleOptionProduct->product_id, 'is_default' => $bundleOptionProduct->is_default, 'sort_order' => $bundleOptionProduct->sort_order, + 'in_stock' => $bundleOptionProduct->product->inventories->sum('qty') >= $bundleOptionProduct->qty, + 'inventory' => $bundleOptionProduct->product->inventories->sum('qty'), ]; } From 36444145c054f4484f24decfa6d0a408fefa636d Mon Sep 17 00:00:00 2001 From: Matt April Date: Fri, 19 Jun 2020 11:29:03 -0400 Subject: [PATCH 3/5] style. --- packages/Webkul/Product/src/Type/Bundle.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 119b792eb..acfdef3f3 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -172,7 +172,7 @@ class Bundle extends AbstractType if (count($optionProductsPrices)) { $selectionMinPrice = min($optionProductsPrices); - if($option->is_required) { + if ($option->is_required) { $minPrice += $selectionMinPrice; } elseif (! $haveRequiredOptions) { $minPrices[] = $selectionMinPrice; @@ -206,7 +206,7 @@ class Bundle extends AbstractType if (count($optionProductsPrices)) { $selectionMinPrice = min($optionProductsPrices); - if($option->is_required) { + if ($option->is_required) { $minPrice += $selectionMinPrice; } elseif (! $haveRequiredOptions) { $minPrices[] = $selectionMinPrice; @@ -661,7 +661,7 @@ class Bundle extends AbstractType { # to consider a bundle in stock we need to check that at least one product from each required group is available for the given quantity foreach ($this->product->bundle_options as $option) { - if($option->is_required) { + if ($option->is_required) { foreach ($option->bundle_option_products as $bundleOptionProduct) { # as long as at least one product in the required group is available we can continue checking other groups if($bundleOptionProduct->product->haveSufficientQuantity($bundleOptionProduct->qty * $qty)) { From e09bf9efb1463abc2402a1812c09c1c72f978df4 Mon Sep 17 00:00:00 2001 From: olaysco Date: Fri, 10 Jul 2020 17:22:11 +0100 Subject: [PATCH 4/5] include config seeders to enable social login by default --- .../src/Database/Seeders/DatabaseSeeder.php | 4 +- .../CustomerSocialAccountTableSeeder.php | 70 +++++++++++++++++++ .../src/Database/Seeders/DatabaseSeeder.php | 18 +++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/Webkul/SocialLogin/src/Database/Seeders/CustomerSocialAccountTableSeeder.php create mode 100644 packages/Webkul/SocialLogin/src/Database/Seeders/DatabaseSeeder.php diff --git a/packages/Webkul/Admin/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/Admin/src/Database/Seeders/DatabaseSeeder.php index dbdaed761..74e764713 100755 --- a/packages/Webkul/Admin/src/Database/Seeders/DatabaseSeeder.php +++ b/packages/Webkul/Admin/src/Database/Seeders/DatabaseSeeder.php @@ -10,6 +10,7 @@ use Webkul\User\Database\Seeders\DatabaseSeeder as UserSeeder; use Webkul\Customer\Database\Seeders\DatabaseSeeder as CustomerSeeder; use Webkul\Inventory\Database\Seeders\DatabaseSeeder as InventorySeeder; use Webkul\CMS\Database\Seeders\DatabaseSeeder as CMSSeeder; +use Webkul\SocialLogin\Database\Seeders\DatabaseSeeder as SocialLoginSeeder; class DatabaseSeeder extends Seeder { @@ -27,5 +28,6 @@ class DatabaseSeeder extends Seeder $this->call(UserSeeder::class); $this->call(CustomerSeeder::class); $this->call(CMSSeeder::class); + $this->call(SocialLoginSeeder::class); } -} \ No newline at end of file +} diff --git a/packages/Webkul/SocialLogin/src/Database/Seeders/CustomerSocialAccountTableSeeder.php b/packages/Webkul/SocialLogin/src/Database/Seeders/CustomerSocialAccountTableSeeder.php new file mode 100644 index 000000000..0303898db --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Database/Seeders/CustomerSocialAccountTableSeeder.php @@ -0,0 +1,70 @@ +insert( + [ + 'code' => 'customer.settings.social_login.enable_facebook', + 'value' => '1', + 'channel_code' => 'default', + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ] + ); + + DB::table('core_config')->insert( + [ + 'code' => 'customer.settings.social_login.enable_twitter', + 'value' => '1', + 'channel_code' => 'default', + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ] + ); + + DB::table('core_config')->insert( + [ + 'code' => 'customer.settings.social_login.enable_google', + 'value' => '1', + 'channel_code' => 'default', + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ] + ); + + DB::table('core_config')->insert( + [ + 'code' => 'customer.settings.social_login.enable_linkedin', + 'value' => '1', + 'channel_code' => 'default', + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ] + ); + + DB::table('core_config')->insert( + [ + 'code' => 'customer.settings.social_login.enable_github', + 'value' => '1', + 'channel_code' => 'default', + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ] + ); + } +} diff --git a/packages/Webkul/SocialLogin/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/SocialLogin/src/Database/Seeders/DatabaseSeeder.php new file mode 100644 index 000000000..57a79251a --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Database/Seeders/DatabaseSeeder.php @@ -0,0 +1,18 @@ +call(CustomerSocialAccountTableSeeder::class); + } +} From 3c371a781c426ff5b29faa04dae69805fb65527e Mon Sep 17 00:00:00 2001 From: jitendra Date: Tue, 14 Jul 2020 12:07:55 +0530 Subject: [PATCH 5/5] Virtual inventory issue fixed --- packages/Webkul/BookingProduct/src/Type/Booking.php | 9 +++++++++ packages/Webkul/Product/src/Type/Virtual.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/BookingProduct/src/Type/Booking.php b/packages/Webkul/BookingProduct/src/Type/Booking.php index 293f65aa0..9e980d9f5 100644 --- a/packages/Webkul/BookingProduct/src/Type/Booking.php +++ b/packages/Webkul/BookingProduct/src/Type/Booking.php @@ -152,6 +152,15 @@ class Booking extends Virtual return app($this->bookingHelper->getTypeHepler($bookingProduct->type))->isItemHaveQuantity($cartItem); } + /** + * @param int $qty + * @return bool + */ + public function haveSufficientQuantity($qty) + { + return true; + } + /** * Add product. Returns error message if can't prepare product. * diff --git a/packages/Webkul/Product/src/Type/Virtual.php b/packages/Webkul/Product/src/Type/Virtual.php index aaa2489a2..6f19a8941 100644 --- a/packages/Webkul/Product/src/Type/Virtual.php +++ b/packages/Webkul/Product/src/Type/Virtual.php @@ -62,6 +62,6 @@ class Virtual extends AbstractType */ public function haveSufficientQuantity($qty) { - return true; + return $qty <= $this->totalQuantity() ? true : false; } } \ No newline at end of file