diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 7e24e7ac8..9860ada1d 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -278,7 +278,7 @@ class Bundle extends AbstractType if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) { continue; } - + if (in_array($option->type, ['multiselect', 'checkbox'])) { if (! isset($optionPrices[$option->id][0])) { $optionPrices[$option->id][0] = 0; @@ -315,7 +315,7 @@ class Bundle extends AbstractType if (! $bundleOptionProduct->product->getTypeInstance()->isSaleable()) { continue; } - + if (in_array($option->type, ['multiselect', 'checkbox'])) { if (! isset($optionPrices[$option->id][0])) { $optionPrices[$option->id][0] = 0; @@ -381,6 +381,25 @@ class Bundle extends AbstractType ]; } + /** + * Get bundle product special price + * + * @return boolean + */ + private function checkBundleProductHaveSpecialPrice() + { + $haveSpecialPrice = false; + foreach ($this->product->bundle_options as $option) { + foreach ($option->bundle_option_products as $index => $bundleOptionProduct) { + if ($bundleOptionProduct->product->getTypeInstance()->haveSpecialPrice()) { + $haveSpecialPrice = true; + break; + } + } + } + return $haveSpecialPrice; + } + /** * Get product minimal price * @@ -390,7 +409,12 @@ class Bundle extends AbstractType { $prices = $this->getProductPrices(); - $priceHtml = '
'; + $priceHtml = ''; + + if ($this->checkBundleProductHaveSpecialPrice()) + $priceHtml .= '
' . trans('shop::app.products.sale') . '
'; + + $priceHtml .= '
'; if ($prices['from']['regular_price']['price'] != $prices['from']['final_price']['price']) { $priceHtml .= '' . $prices['from']['regular_price']['formated_price'] . '' diff --git a/packages/Webkul/Product/src/Type/Grouped.php b/packages/Webkul/Product/src/Type/Grouped.php index bb13a3e8a..a137b8a4c 100644 --- a/packages/Webkul/Product/src/Type/Grouped.php +++ b/packages/Webkul/Product/src/Type/Grouped.php @@ -139,6 +139,23 @@ class Grouped extends AbstractType return min($minPrices); } + /** + * Get group product special price + * + * @return boolean + */ + private function checkGroupProductHaveSpecialPrice() + { + $haveSpecialPrice = false; + foreach ($this->product->grouped_products as $groupOptionProduct) { + if ($groupOptionProduct->associated_product->getTypeInstance()->haveSpecialPrice()) { + $haveSpecialPrice = true; + break; + } + } + return $haveSpecialPrice; + } + /** * Get product minimal price * @@ -146,9 +163,16 @@ class Grouped extends AbstractType */ public function getPriceHtml() { - return '' . trans('shop::app.products.starting-at') . '' - . ' ' - . '' . core()->currency($this->getMinimalPrice()) . ''; + $html = ''; + + if ($this->checkGroupProductHaveSpecialPrice()) + $html .= '
' . trans('shop::app.products.sale') . '
'; + + $html .= '' . trans('shop::app.products.starting-at') . '' + . ' ' + . '' . core()->currency($this->getMinimalPrice()) . ''; + + return $html; } /**