Как вывести перечеркнутую цену и цену со скидкой Virtuemart 2.0
Итак, у нас задача, необходимо вывести в магазине на Virtuemart 2.0 две цены - старую перечеркутую цену и новую со скидкой соответственно.
Вначале модифицируем файл, отвечающий за отображение цены в карточке товара:
Скорее всего Вы используете шаблон, по этому правим файл Вашего шаблона.
/templates/ваш_шаблон/html/com_virtuemart/productdetails/default.php
Поскольку в моем случае цена содержит налог с оборота, комментируем следующие строки:
1.
//echo $this->currency->createPriceDiv ( 'basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices );
2.
//echo $this->currency->createPriceDiv ( 'salesPriceWithDiscount', //'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices );
//echo $this->currency->createPriceDiv ( 'priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', //$this->product->prices );
3.
//echo $this->currency->createPriceDiv ( 'salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices );
После строк из пункта 2 (см.выше) вставляем код:
if($this->product->prices[salesPrice] != $this->product->prices['basePriceWithTax']) {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices);
} else {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', '');
}
--------------------------------------------------------------------------------------------------------------
Ок, в карточке товара с ценами порядок.
Разберемся с категориями:
Идем сюда: /templates/ваш_шаблон/html/com_virtuemart/category/default.php
Коментим эти строки:
//echo $this->currency->createPriceDiv('salesPrice','',$product->prices);
//echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);
//echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);
Ниже этих строк вставляем условие:
if($product->prices[salesPrice] != $product->prices[basePriceWithTax]) {
echo $this->currency->createPriceDiv('salesPrice', '' , $product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', '', $product->prices);
} else {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', '', '');
}
В категоиях теперь тоже видно две цены.
Для модуля и главной виртуемарта я условия не прописываю, поскольку у меня нет этих вещей. Но ковырять пришлось бы файлы modules/mod_virtuemart_product/tmpl/default.php и components\com_virtuemart\views\virtuemart\tmpl\default_products.php - или в шаблоне сайта.
Теперь пропишем стили, чтобы старая цена была перечеркнута:
span.PricebasePriceWithTax {
text-decoration: line-through;
}
Вначале модифицируем файл, отвечающий за отображение цены в карточке товара:
Скорее всего Вы используете шаблон, по этому правим файл Вашего шаблона.
/templates/ваш_шаблон/html/com_virtuemart/productdetails/default.php
Поскольку в моем случае цена содержит налог с оборота, комментируем следующие строки:
1.
//echo $this->currency->createPriceDiv ( 'basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices );
2.
//echo $this->currency->createPriceDiv ( 'salesPriceWithDiscount', //'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices );
//echo $this->currency->createPriceDiv ( 'priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', //$this->product->prices );
3.
//echo $this->currency->createPriceDiv ( 'salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices );
После строк из пункта 2 (см.выше) вставляем код:
if($this->product->prices[salesPrice] != $this->product->prices['basePriceWithTax']) {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices);
} else {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', '');
}
--------------------------------------------------------------------------------------------------------------
Ок, в карточке товара с ценами порядок.
Разберемся с категориями:
Идем сюда: /templates/ваш_шаблон/html/com_virtuemart/category/default.php
Коментим эти строки:
//echo $this->currency->createPriceDiv('salesPrice','',$product->prices);
//echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);
//echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);
Ниже этих строк вставляем условие:
if($product->prices[salesPrice] != $product->prices[basePriceWithTax]) {
echo $this->currency->createPriceDiv('salesPrice', '' , $product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', '', $product->prices);
} else {
echo $this->currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax', '', '');
}
В категоиях теперь тоже видно две цены.
Для модуля и главной виртуемарта я условия не прописываю, поскольку у меня нет этих вещей. Но ковырять пришлось бы файлы modules/mod_virtuemart_product/tmpl/default.php и components\com_virtuemart\views\virtuemart\tmpl\default_products.php - или в шаблоне сайта.
Теперь пропишем стили, чтобы старая цена была перечеркнута:
span.PricebasePriceWithTax {
text-decoration: line-through;
}
Предлагаю вашему вниманию подборку интересных каналов Telegram по дизайну интерьера и архитектуре
https://tele.gg/dizain_interjera - канал практикующего дизайнера интерьера с интересными советами по ремонту и декору.
https://tele.gg/interio_inspiration - канал с ежедневной подборкой проектов интерьера для вашего вдохновения
https://tele.gg/arh_inspiration - так же подборка вдохновляющих проектов, но уже по архитектуре
Спасибо, выручили!
ОтветитьУдалить