News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

if no discount then hide crossed base price

Started by claesbas, March 27, 2013, 13:04:56 PM

Previous topic - Next topic

claesbas

Hello,

Can someone please instruct me on how to write a script that hides the crossed baseprice if the product has no discount.

Now its:
Baseprise 25
Price 25

it looks great if there is a discount
Baseprise 35
Price 25
Discount 10

So a if statement that hides the crossed baseprice for products that hvae no discount or vice versa.

VMuikit - A Virtuemart theme for Yootheme template
https://joomlapro.com/vmuikit

VMonepage - One Page Checkout (Was free - now is €20)
https://joomlapro.com/product/virtuemart-one-page-checkout

VMKCO - Klarna Checkout Enhanced
https://joomlapro.com/product/virtuemart-klarna-checkout

gpessoa

J 4.4.4; VM 4.2.6; PHP 8.3.6

Shibumi

I have an issue where if no sale price (or discount) is applied to a product, it still displays "Sale Price" for the product as the cost price when logged in (-default- shoppergroup) like this:
Regular Price: $749.99
Sale Price: $749.99

and when not logged in (-anonymous- shoppergroup) it displays like this (it does not display "Regular Price:"):
Sale Price: $749.99

If there is no discount or price override, why does it even show the "Sale Price:" and amount?? it should only show "Regular Price:" and amount.

If there is a discount or sale price, it will display like this:
Sale Price: $854.99
You Save: $95.00
and does not display "Regular Price:" to -anonymous- shoppergroup.

Ideas
Jeff
=================================================
Scionergy.com - www.Scionergy.com
Scion Owners Club of Ottawa - www.ScionOwnersClubOttawa.ca
Capital Door Service - www.CapitalDoorService.com - VM2.0.20b, Joomla 2.5.11 PHP5.2.11 powered site

Fries

Quote from: gpessoa on March 28, 2013, 01:16:57 AM
VM already do that.

No, it doesn't. Recently there is only two way: showing base and discount prices together even if they are the same or not showing discount/base price at all

Peter Pillen

#4
VM actually does this already ... but not quite correct.

If you will check in your virtuemart backend in the prices of a product, you may notice that the productprice for example €39 will be transformed to 39.0000061 and the final salesprice will be transformed to 39.00001. Vm then does the check "is the final salesprice smaller than the baseprice with tax?" result "goody! I found a discount and will display that!"

Two solutions

(1) in your final salesprice, you can force the final salesprice to be bigger than the first 39.0000061 and make it for example 39.0000099. Both prices will be rounded to 39 in the display and VM will not trigger the discount.

(2) solution 1 will not always work (especially in the invoice). But there you can alter the code in the file components\com_virtuemart\views\invoice\tmpl\invoice_items.php The code that determines if the discounted price must be shown is

<?php if(!empty($item->product_basePriceWithTax) && $item->product_basePriceWithTax != $item->product_final_price ) {
echo '<span class="line-through" >'.$this->currency->priceDisplay($item->product_basePriceWithTax,$this->currency,$qtt) .'</span><br />' ;
}
elseif (empty($item->product_basePriceWithTax) && $item->product_item_price != $item->product_final_price) {
echo '<span class="line-through">' . $this->currency->priceDisplay($item->product_item_price,$this->currency,$qtt) . '</span><br />';
}
?>

You can understand that $item->product_basePriceWithTax != $item->product_final_price compares the prices without rounding like 39.0000061 versus 39.000001. So adding a rounded comparison with two decimals is more correct/realistic. Below you can see my adaptations which fixed this discount issue and in the same way you can do this check in many other views such as productdetails.

<?php if(!empty($item->product_basePriceWithTax) && round($item->product_basePriceWithTax,2) != round($item->product_final_price,2) ) {
echo '<span class="line-through" >'.$this->currency->priceDisplay($item->product_basePriceWithTax,$this->currency,$qtt) .'</span><br />' ;
}
elseif (empty($item->product_basePriceWithTax) && round($item->product_item_price,2) != round($item->product_final_price,2)) {
echo '<span class="line-through">' . $this->currency->priceDisplay($item->product_item_price,$this->currency,$qtt) . '</span><br />';
}
?>

kogos

i know that this is an old topic, but since people are coming here from google, looking for an answer, i had to mention this:

the above method works great, but now there is an option in configuration-> pricing that makes things easier. Just disable  "Round only display" and the crossed price will be hidden if there's no discount. However, please check that your prices are correct in frontend after doing this.

Ed Kiefer

When I disable "Round only display", it still shows 2 prices.

Jörgen

Probably a template issue, please test with Protostar.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.