VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: talitali on January 30, 2015, 09:49:29 AM

Title: Show Discount as % not amount
Post by: talitali on January 30, 2015, 09:49:29 AM
I have read past articles but they dont seem to work in virtuemart 3, how to change the display from amount to percentages in product display? thank you

http://forum.virtuemart.net/index.php?topic=126620.0

http://forum.virtuemart.net/index.php?topic=106402.0
Title: Re: Show Discount as % not amount
Post by: AH on January 30, 2015, 09:57:05 AM
My method works and is tested
http://forum.virtuemart.net/index.php?topic=126620.0 (http://forum.virtuemart.net/index.php?topic=126620.0)

reply #3
Title: Re: Show Discount as % not amount
Post by: talitali on January 30, 2015, 10:01:07 AM
I see your code but where do you put it?  which file and where? thank you
Title: Re: Show Discount as % not amount
Post by: AH on January 30, 2015, 10:15:48 AM
http://forum.virtuemart.net/index.php?topic=79799.0 (http://forum.virtuemart.net/index.php?topic=79799.0)
Title: Re: Show Discount as % not amount
Post by: talitali on January 30, 2015, 13:58:40 PM
you put the wrong link ,I have already said in my first post version 3  8) .can any one else help please?with solution that works in vm 3
Title: Re: Show Discount as % not amount
Post by: AH on January 30, 2015, 14:20:28 PM
 ::)

Prices are now controlled by a sublayout

Put the change in the override

templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/prices.php (http://templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/prices.php)

The solution works for VM3
Title: Re: Show Discount as % not amount
Post by: talitali on January 30, 2015, 15:51:58 PM
   Warning: Division by zero in url/public_html/components/com_virtuemart/sublayouts/prices.php on line 52

this is line 52

   $discount_percent = round(($product->prices['basePriceWithTax'] - $product->prices['salesPrice']) * 100 /

this is the warning why is that?
Title: Re: Show Discount as % not amount
Post by: AH on January 30, 2015, 17:03:59 PM
No idea

Try debugging in a development environment and see what is happening with the variables.

Or maybe someone else might have time to do the work for you.
Title: problem solved
Post by: talitali on January 30, 2015, 19:44:37 PM
I had to use  $product->prices['basePrice'] and not $product->prices['basePriceWithTax'].

god I miss woocommerce   ;D
Title: Re: Show Discount as % not amount
Post by: Milbo on February 01, 2015, 16:40:20 PM
use basePriceVariant!
Title: Re: Show Discount as % not amount
Post by: AH on February 01, 2015, 17:32:40 PM
BasepriceVariant does not give the correct calculation if used in:-
$discount_percent = round(($product->prices['basePriceWithTax'] - $product->prices['salesPrice']) * 100 / $product->prices['basePriceWithTax']);

However, this is probably a much better way of achieving the %age using the suggested basePriceVariant !

$discount_percent = round(($product->prices['discountAmount'] / $product->prices['basePriceVariant']) * 100);