This commit is contained in:
Pranshu Tomar 2020-06-08 16:10:53 +05:30
parent 31b9ae7e3e
commit d2ff59cc15
3 changed files with 41 additions and 11 deletions

View File

@ -21,7 +21,7 @@ mix.js(__dirname + "/src/Resources/assets/js/app.js", "js/admin.js")
processCssUrls: false
});
if (!mix.inProduction()) {
if (! mix.inProduction()) {
mix.sourceMaps();
}

View File

@ -36,7 +36,13 @@ class BundleOption extends AbstractProduct
$options = [];
foreach ($this->product->bundle_options as $option) {
$options[$option->id] = $this->getOptionItemData($option);
$data = $this->getOptionItemData($option);
if (! count($data['products'])) {
continue;
}
$options[$option->id] = $data;
}
usort ($options, function($a, $b) {
@ -79,6 +85,10 @@ class BundleOption extends AbstractProduct
$products = [];
foreach ($option->bundle_option_products as $index => $bundleOptionProduct) {
if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) {
continue;
}
$products[$bundleOptionProduct->id] = [
'id' => $bundleOptionProduct->id,
'qty' => $bundleOptionProduct->qty,

View File

@ -234,6 +234,10 @@ class Bundle extends AbstractType
$optionPrices = [];
foreach ($option->bundle_option_products as $index => $bundleOptionProduct) {
if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) {
continue;
}
$optionPrices[] = $bundleOptionProduct->qty
* ($minPrice
? $bundleOptionProduct->product->getTypeInstance()->getMinimalPrice()
@ -271,6 +275,10 @@ class Bundle extends AbstractType
foreach ($this->product->bundle_options as $option) {
foreach ($option->bundle_option_products as $index => $bundleOptionProduct) {
if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) {
continue;
}
if (in_array($option->type, ['multiselect', 'checkbox'])) {
if (! isset($optionPrices[$option->id][0])) {
$optionPrices[$option->id][0] = 0;
@ -304,6 +312,10 @@ class Bundle extends AbstractType
foreach ($this->product->bundle_options as $option) {
foreach ($option->bundle_option_products as $index => $bundleOptionProduct) {
if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) {
continue;
}
if (in_array($option->type, ['multiselect', 'checkbox'])) {
if (! isset($optionPrices[$option->id][0])) {
$optionPrices[$option->id][0] = 0;
@ -427,6 +439,10 @@ class Bundle extends AbstractType
foreach ($this->getCartChildProducts($data) as $productId => $data) {
$product = $this->productRepository->find($productId);
if (! $product->getTypeInstance()->isSaleable()) {
continue;
}
$cartProduct = $product->getTypeInstance()->prepareForCart(array_merge($data, ['parent_id' => $this->product->id]));
if (is_string($cartProduct)) {
@ -473,6 +489,10 @@ class Bundle extends AbstractType
'product_bundle_option_id' => $optionId,
]);
if (! $optionProduct->product->getTypeInstance()->isSaleable()) {
continue;
}
$qty = $data['bundle_option_qty'][$optionId] ?? $optionProduct->qty;
if (! isset($products[$optionProduct->product_id])) {