Hi, in the company website we want to achieve the following goals:
1 - In the category view, show only the product base price without taxes and discount applied.
2 - In the product view, show the base price, the base price with discount (if any), the Tax (VAT) value and the discount value.
3 - In the cart view, we need to show the total price with discount and taxes all applied.
I tried to modify some CSS rules but all three views are controlled by the same rule. I found a couple of locations where the code of VirtueMart print out the prices but I was not able to obtain any result on the website by editing the code in there.
In particular I tried to change the followings file:
- com_virtuemart/views/productdetails/tmpl/default.php
- com_virtuemart/views/productdetails/tmpl/default_pdf.php
- com_virtuemart/views/category/tmpl/default.php
- com_virtuemart/views/category/view_feed.php
My approach is to find the place where the price is generated and surround the code with a <div>
with a custom class for a new CSS rule and choose what to hide and what to show.
Any suggestion on how to find the right lines of code to edit?
The website specifications are:
- Joomla! v 3.10.11
- VirtueMart v 4.0.12
just duplicate or triplicate the templates\your_template\html\com_virtuemart\sublayouts\prices.php
prices_cats.php
prices_detail.php
etc
and adjust them to show what u want .. and call them in the templates
echo shopFunctionsF::renderVmSubLayout('prices_detail',array('product'=>$this->product,'currency'=>$this->currency));
Quote from: GJC Web Design on February 10, 2023, 12:18:46 PM
just duplicate or triplicate the templates\your_template\html\com_virtuemart\sublayouts\prices.php
prices_cats.php
prices_detail.php
etc
and adjust them to show what u want .. and call them in the templates
echo shopFunctionsF::renderVmSubLayout('prices_detail',array('product'=>$this->product,'currency'=>$this->currency));
Ohh, thank you very much for the tips! I will try this!
Ok, I managed to show only the price I want to, but I can't make disappear the 'discounted price' if it is equal to the 'base price'.
In my override I wrote this code:
/* ... */
if (round($product->prices['basePrice'], $currency->_priceConfig['basePrice'][1]) != round($product->$prices['discountedPriceWithoutTax'], $currency->_priceConfig['discountedPriceWithoutTax'][1])) {
echo '<span style="text-decoration: line-through;" >' . $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices) . '</span>';
echo $currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
} else {
echo $currecy->createDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
}
/* ... */
My goal is to show the discounted price only if it's different from the base price, and in this case the base price should have a strikethrough. if they are equals, only the base price should be visible.
Where is my mistake?