VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: framos41 on April 06, 2018, 15:59:02 PM

Title: Discount percentaje in badge
Post by: framos41 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!
Title: Re: Discount percentaje in badge
Post by: changlee on June 15, 2019, 18:12:42 PM
Please check: https://extensions.joomla.org/extension/vm-discount-percent-badge/
Title: Re: Discount percentaje in badge
Post by: StefanSTS 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:


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);
}
Title: Re: Discount percentaje in badge
Post by: framos41 on October 15, 2019, 22:05:51 PM
Quote from: StefanSTS 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:


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!
Title: Re: Discount percentaje in badge
Post by: pinochico 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