News:

Support the VirtueMart project and become a member

Main Menu

Show percentage of the discount

Started by neviomaria, March 29, 2012, 15:48:48 PM

Previous topic - Next topic

neviomaria

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]

francescomac82

I have the same problem!
Any solution?

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


Thanks

neviomaria

Ciao , non purtroppo nessuna soluzione per il momento.

karuppiah

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.
karuppiah

K&K media production

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

karuppiah

Hi, i know this is a core hack can you explain me in detail how i can modify to percentage?
karuppiah

K&K media production

#6
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

karuppiah

karuppiah