Baseprice with Tax always crossed out, even without discount

Started by BjornOnPole, May 23, 2014, 10:14:41 AM

Previous topic - Next topic

BjornOnPole

Joomla version:  2.5.20
VirtueMart version: 2.6.4
PHP version: 5.4.10
Bug is also present in Beez5 template: Yes
OS: OSX
SSL: No
SEF: Yes

URL: http://onpole.org/testomgeving/ss/virtuemart/cilinders/cilinders-met-gecertificeerde-sleutels/evva-3ks
The bug is also present in the product-view: http://onpole.org/testomgeving/ss/virtuemart/cilinders/cilinders-met-gecertificeerde-sleutels/evva-3ks/3ks-certificaat-en-3-sleutels-alleen-1e-levering-detail

Description of the problem:

I've configured Virtuemart to show the Baseprice with Tax, and (if available) the Discount Price.
In the category view and in the product view, the Baseprice with Tax is always crossed out, even when there is no discount.

I've found a solution:

In components/com_virtuemart/views/category/tmpl/default.php there are the following lines:

if (round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
   echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
}

This IF statement is not correct.
round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) will never be the same as $product->prices['salesPrice'].

Here are some example values:

round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) = 44.83
$product->prices['salesPrice'] = 44.8305

These prices are not the same, and so the price will always be crossed out.

Replace those lines with (in a template override):

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != round($product->prices['salesPrice'],$this->currency->_priceConfig['salesPrice'][1])) {
                     
echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";

}

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) == round($product->prices['salesPrice'],$this->currency->_priceConfig['salesPrice'][1])) {
                     
echo '<div class="" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";

}


And in components/com_virtuemart/views/productdetails/tmpl/default_showprices.php:

Replace

if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {

   echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";

}

with

if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != round($this->product->prices['salesPrice'],$this->currency->_priceConfig['salesPrice'][1])) {
                     
   echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";

}

if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) == round($this->product->prices['salesPrice'],$this->currency->_priceConfig['salesPrice'][1])) {
                     
   echo '<span class="" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";

}

This will cross the price out if there is discount, but not if there is no discount.


This bug was present in the previous version of VirtueMart too. It would be great if this was fixed in the next update.

Please look into this issue for me.

BjornOnPole

This issue is still present in the newest update (VirtueMart 2.6.4).

The check for wether or not the price should be crossed still is:

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) { }

These two variables will never be the same, because the second one has more characters.


GJC Web Design

I posted a fix for this a while back (2-3 weeks from memory) - and yes it's still a problem in 2.6.4
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