News:

Looking for documentation? Take a look on our wiki

Main Menu

show original price, discounted price and discount percentage

Started by arie, January 10, 2012, 14:24:45 PM

Previous topic - Next topic

zczfwz

Quote from: karuppiah on July 30, 2013, 12:37:40 PM
In virtuemart 2.0 We can display discount percentage in two simple steps,

Step 1:
Open,administrator/components/com_virtuemart/helpers/calculationh.php,

Around line 352,you can find this line $prices['discountAmount'] = $this->roundInternal($basePriceWithTax - $salesPrice);

Replace with,$prices['discountAmount'] = $this->roundInternal(($basePriceWithTax - $prices['salesPrice']) * 100 / $basePriceWithTax);

here i am doing simple % calculation so the percentage of product will be shown like this for ex,$20.00

Step2:

In product detailed page or category pages,

To display default discount this code is used, $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

Assign the variable for this code like,

$vars=$this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

to remove the currency symbol and decinal points use string replace like below,

$cuur1= str_replace('$(your currency symbol)','',$vars);
echo $cuur2= str_replace('.00','%',$cuur1);

Now the amount will be dsipalyed as percentage.

Hi karuppiah,

Thanks for you solution for adding discount percentage, I've tried and it works for non-children products, but I found it doesn't work with Child products (I used generic child variant).
I can see after loading the child product details page, the "%" shows in first couple of seconds but gets overwrite by "$" symbol eventually.
I guess there is some code elsewhere that load the "$" symbol again for child products.
Do you know where it is?

Thanks

szeor

Quote from: soniamesotek10 on March 21, 2012, 11:35:16 AM
hi, i m new to Joomla & Virtue Mart, i installed 1.5 Joomla & Virtuemart version 2.0.0

1) i want  the same, show original price, discounted price and discount percentage but its showing only Sales price & Discount in my website

2) Also i want to change the font color as below:
a) original price--i want font with strike with line-through
b) discounted price --- red & bold font
c) discount---------green font

do i need to change any CSS for this,

thanks, please help

firefox, firebug, right click, css path?

pm4698

Hello there.

I used this method too and its not working 100%.

At the replace of currency symbol topic, if you have euro, try this:

$newcurr= str_replace(chr(0xE2).chr(0x82).chr(0xAC), '', $vars);

because otherwise Euro character is not recognized

So, if i echo $newcurr, then i can see my percentage, without % symbol and with decimals.
If i use the next line:

$newcurr2=str_replace(',00','%',$newcurr);?>

and echo $newcurr2 variable then my decimals are still there. I also tried round function with no success. Any idea of how to make decimals disappear?

Thank you in advance

wlaagewaard


OriyanJ

Whenever I change quantity, crossed price disappears. Any thoughts?
VirtueMart 3.2.2

xenofon360

Hi there guys,

I found this whole conversation here very  interesting and i've tested / combined almost all of the methods here in my VM e-shop but i still got a problem.
The problem is that i am using Joomla 3 with virtuemart 3 too and some of the coding lines in php files don't exist anymore, maybe they've been replaced or repealed.

I want my shop showing the price of the product like this : old price (deleted with a line)
                                                                                            base price
                                                                                            money saved

Also i want that to take action to the categories page and into the product page for each product.

If there is someone who can explain step by step the procedure for that i would be grateful !