News:

Support the VirtueMart project and become a member

Main Menu

Show Discount as % not amount

Started by talitali, January 30, 2015, 09:49:29 AM

Previous topic - Next topic

talitali

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

AH

Regards
A

Joomla 4.4.5
php 8.1

talitali

I see your code but where do you put it?  which file and where? thank you

AH

Regards
A

Joomla 4.4.5
php 8.1

talitali

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

AH

 ::)

Prices are now controlled by a sublayout

Put the change in the override

templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/prices.php

The solution works for VM3
Regards
A

Joomla 4.4.5
php 8.1

talitali

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

AH

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.
Regards
A

Joomla 4.4.5
php 8.1

talitali

I had to use  $product->prices['basePrice'] and not $product->prices['basePriceWithTax'].

god I miss woocommerce   ;D

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

#10
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);


Regards
A

Joomla 4.4.5
php 8.1