diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index a85ec3bb6..925ceb3a6 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -635,7 +635,11 @@ class Configurable extends AbstractType */ public function getPriceHtml() { - if ($this->haveOffer()) { + if ($this->haveSpecialPrice()) { + return '
' . trans('shop::app.products.sale') . '
' + . '' . trans('shop::app.products.price-label') . '' + . '' . core()->currency($this->evaluatePrice($this->getMinimalPrice())) . ''.''; + } elseif ($this->haveOffer()) { return '
' . trans('shop::app.products.sale') . '
' . '' . trans('shop::app.products.price-label') . '' . '' . core()->currency($this->evaluatePrice($this->getMinimalPrice())) . '' @@ -647,6 +651,27 @@ class Configurable extends AbstractType } } + /** + * Check whether configurable product have special price. + * + * @param int $qty + * @return bool + */ + public function haveSpecialPrice($qty = null) + { + $haveSpecialPrice = false; + + foreach ($this->product->variants as $variant) { + if ($variant->getTypeInstance()->haveSpecialPrice()) { + $haveSpecialPrice = true; + + break; + } + } + + return $haveSpecialPrice; + } + /** * Add product. Returns error message if can't prepare product. * diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php index 54778d8d0..a7b7352f2 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php @@ -297,7 +297,7 @@ }); let priceLabelElement = document.querySelector('.price-label'); - let priceElement = document.querySelector('.final-price'); + let priceElement = document.querySelector('.special-price') ? document.querySelector('.special-price') : document.querySelector('.final-price'); let regularPriceElement = document.querySelector('.regular-price'); if (this.childAttributes.length == selectedOptionCount) { diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php index 9287e8bcb..4e9db1f84 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php @@ -314,7 +314,7 @@ }); let priceLabelElement = document.querySelector('.price-label'); - let priceElement = document.querySelector('.special-price'); + let priceElement = document.querySelector('.special-price') ? document.querySelector('.special-price') : document.querySelector('.final-price'); let regularPriceElement = document.querySelector('.regular-price'); if (this.childAttributes.length == selectedOptionCount) { @@ -325,7 +325,7 @@ } priceElement.innerHTML = this.config.variant_prices[this.simpleProduct].final_price.formated_price; - + if ( this.config.variant_prices[this.simpleProduct].regular_price.formated_price == "$0.00" || this.config.variant_prices[this.simpleProduct].regular_price.formated_price == this.config.variant_prices[this.simpleProduct].final_price.formated_price