VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: neviomaria on March 29, 2012, 15:48:48 PM

Title: Show percentage of the discount
Post by: neviomaria on March 29, 2012, 15:48:48 PM
Hello everyone,

I nedd to enter the percentage of the discount instead of the amount of the discount in the product flypage?

Joomla 2.5 Virtuemart 2.0.2

thanks

[attachment cleanup by admin]
Title: Re: Show percentage of the discount
Post by: francescomac82 on May 12, 2012, 12:05:21 PM
I have the same problem!
Any solution?

Ho lo stesso problema, mica hai trovato giĆ  qualche soluzione??


Thanks
Title: Re: Show percentage of the discount
Post by: neviomaria on May 12, 2012, 12:14:33 PM
Ciao , non purtroppo nessuna soluzione per il momento.
Title: Show percentage of the discount
Post by: karuppiah on July 30, 2013, 12:32:42 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.
Title: Re: Show percentage of the discount
Post by: K&K media production on July 30, 2013, 19:47:21 PM
this is a core hack...a better way: make a template override, put your % calculation in the override and output the result instead the discount amount
Title: Re: Show percentage of the discount
Post by: karuppiah on July 31, 2013, 13:19:08 PM
Hi, i know this is a core hack can you explain me in detail how i can modify to percentage?
Title: Re: Show percentage of the discount
Post by: K&K media production on July 31, 2013, 19:51:13 PM
The same way like yours. But put the calculation not in the calculation helper, put it in your template override. And then output the result in your template override on the place where momently the discount amount is.

Here more about overrides, if you don't know
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Title: Re: Show percentage of the discount
Post by: karuppiah on August 07, 2013, 12:00:51 PM
Ok,Thanks for this information..