Author Topic: Discount percentaje in badge  (Read 514 times)

framos41

  • Beginner
  • *
  • Posts: 19
Discount percentaje in badge
« on: April 06, 2018, 15:59:02 pm »
Hello! Does anybody know hoy you can show the discount percentage in the product badge? im using virtuemart 3.2.14 Regards!

changlee

  • Beginner
  • *
  • Posts: 41
    • Web design BLB.gr
Free SMTP Newsletter at https://www.emailbat.com and my complete SEO services at http://www.blb.gr

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 412
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Discount percentaje in badge
« Reply #2 on: June 17, 2019, 13:01:15 pm »
You can make an override for the productdetails layout and calculate the percentage there.

It's just a simple calculation like this:

Code: [Select]
if ($product->prices['basePriceWithTax'] != 0) { // with tax
$percentDiscount = round($product->prices['discountAmount'] / $product->prices['basePriceWithTax'] * 100, 0);
} elseif ($product->prices['basePrice'] != 0) { // without tax
$percentDiscount = round($product->prices['discountAmount'] / $product->prices['basePrice'] * 100, 0);
}
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your life shop! Use Alpha versions only if you know what risk you are taking.