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

framos41

  • Beginner
  • *
  • Posts: 20
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
  • Full Member
  • *
  • Posts: 520
  • 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 live shop! Use Alpha versions only if you know what risk you are taking.

framos41

  • Beginner
  • *
  • Posts: 20
Re: Discount percentaje in badge
« Reply #3 on: October 15, 2019, 22:05:51 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);
}

Thank you! how do you apply this? regards!

pinochico

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 42
    • MiniJoomla
  • VirtueMart Version: 3
Re: Discount percentaje in badge
« Reply #4 on: October 16, 2019, 07:32:16 am »
Hi,

please check this plugin:
https://www.minijoomla.org/extensions/virtuemart-extensions/product-labels-for-virtuemart

One from 9 labels is sale with percent.
Three labels are added as new checkbox in product detail in administration.
For labels you can setup color or picture

Rudolf
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates