Merge branch 'master' of https://github.com/bagisto/bagisto into development

This commit is contained in:
rahulshukla-home 2020-07-14 18:04:16 +05:30
commit 012b2c2b6b
7 changed files with 131 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -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.
*

View File

@ -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) {
$data = $this->getOptionItemData($option);
@ -97,6 +100,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'),
];
}

View File

@ -173,7 +173,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;
@ -207,7 +207,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;
@ -674,4 +674,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;
}
}

View File

@ -62,6 +62,6 @@ class Virtual extends AbstractType
*/
public function haveSufficientQuantity($qty)
{
return true;
return $qty <= $this->totalQuantity() ? true : false;
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace Webkul\SocialLogin\Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class CustomerSocialAccountTableSeeder extends Seeder
{
public function run()
{
$now = Carbon::now();
DB::table('core_config')->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,
]
);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Webkul\SocialLogin\Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call(CustomerSocialAccountTableSeeder::class);
}
}