News:

Support the VirtueMart project and become a member

Main Menu

Differentiate price shown between product page, category view and cart

Started by NickExnIT, February 10, 2023, 11:39:43 AM

Previous topic - Next topic

NickExnIT

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



GJC Web Design

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));
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

NickExnIT

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!

NickExnIT

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?