Merge pull request #6720 from papnoisanjeev/sale-icon-config-product-for-spacial-price
Special price option added product if spacial price exist for configurable product. #6699
This commit is contained in:
commit
21f2d81862
|
|
@ -635,7 +635,11 @@ class Configurable extends AbstractType
|
|||
*/
|
||||
public function getPriceHtml()
|
||||
{
|
||||
if ($this->haveOffer()) {
|
||||
if ($this->haveSpecialPrice()) {
|
||||
return '<div class="sticker sale">' . trans('shop::app.products.sale') . '</div>'
|
||||
. '<span class="price-label">' . trans('shop::app.products.price-label') . '</span>'
|
||||
. '<span class="special-price">' . core()->currency($this->evaluatePrice($this->getMinimalPrice())) . '</span>'.'<span class="regular-price"></span>';
|
||||
} elseif ($this->haveOffer()) {
|
||||
return '<div class="sticker sale">' . trans('shop::app.products.sale') . '</div>'
|
||||
. '<span class="price-label">' . trans('shop::app.products.price-label') . '</span>'
|
||||
. '<span class="regular-price">' . core()->currency($this->evaluatePrice($this->getMinimalPrice())) . '</span>'
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue