News:

Looking for documentation? Take a look on our wiki

Main Menu

Discount percentaje in badge

Started by framos41, April 06, 2018, 15:59:02 PM

Previous topic - Next topic

framos41

Hello! Does anybody know hoy you can show the discount percentage in the product badge? im using virtuemart 3.2.14 Regards!


StefanSTS

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);
}
--
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

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!

pinochico

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 for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products