From 4fd6599bda950388a06c98a8afc2834a1973939e Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 27 Jan 2020 13:24:22 +0530 Subject: [PATCH] Issue #2147 --- .../Product/src/Helpers/BundleOption.php | 21 +++++++++++++++++-- packages/Webkul/Product/src/Type/Bundle.php | 4 ++-- .../products/view/bundle-options.blade.php | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/Webkul/Product/src/Helpers/BundleOption.php b/packages/Webkul/Product/src/Helpers/BundleOption.php index b3232ad36..396a83a6e 100644 --- a/packages/Webkul/Product/src/Helpers/BundleOption.php +++ b/packages/Webkul/Product/src/Helpers/BundleOption.php @@ -45,6 +45,14 @@ class BundleOption extends AbstractProduct $options[$option->id] = $this->getOptionItemData($option); } + usort ($options, function($a, $b) { + if ($a['sort_order'] == $b['sort_order']) { + return 0; + } + + return ($a['sort_order'] < $b['sort_order']) ? -1 : 1; + }); + return $options; } @@ -68,7 +76,7 @@ class BundleOption extends AbstractProduct /** * Get formed data from bundle option product - * + * * @param ProductBundleOption $option * @return array */ @@ -83,10 +91,19 @@ class BundleOption extends AbstractProduct 'price' => $bundleOptionProduct->product->getTypeInstance()->getProductPrices(), 'name' => $bundleOptionProduct->product->name, 'product_id' => $bundleOptionProduct->product_id, - 'is_default' => $bundleOptionProduct->is_default + 'is_default' => $bundleOptionProduct->is_default, + 'sort_order' => $bundleOptionProduct->sort_order ]; } + usort ($products, function($a, $b) { + if ($a['sort_order'] == $b['sort_order']) { + return 0; + } + + return ($a['sort_order'] < $b['sort_order']) ? -1 : 1; + }); + return $products; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 1a03ead69..6a6ddc529 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -535,12 +535,12 @@ class Bundle extends AbstractType continue; $optionProduct = $this->productBundleOptionProductRepository->find($optionProductId); - + $qty = $data['bundle_option_qty'][$optionId] ?? $optionProduct->qty; if (! isset($data['bundle_option_qty'][$optionId])) $bundleOptionQuantities[$optionId] = $qty; - + $labels[] = $qty . ' x ' . $optionProduct->product->name . ' ' . core()->currency($optionProduct->product->getTypeInstance()->getMinimalPrice()); } diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/bundle-options.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/bundle-options.blade.php index cd7d13fbd..8b2f4b521 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/bundle-options.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/bundle-options.blade.php @@ -182,7 +182,7 @@ data: function() { return { selected_product: (this.option.type == 'checkbox' || this.option.type == 'multiselect') ? [] : null, - + qty_validations: '' } },