News:

Looking for documentation? Take a look on our wiki

Main Menu

Discountpercentage in Std VM view

Started by SPABO, March 01, 2014, 19:25:53 PM

Previous topic - Next topic

SPABO

The following code works nicely in de view productdetails/tmp/default_showprices.hp


if (round($this->product->prices['discountAmount'] != 0 )) {
$discount_percent = round(($this->product->prices['basePriceWithTax'] - $this->product->prices['salesPrice']) * 100 / $this->product->prices['basePriceWithTax']);
?>
        <div class="discountAmount">
            Save <?php echo $discount_percent?>%
        </div>
<?php
}


But now I would like to see this in the view:

Virtuemart/tmp/default_products.php

But I can't get it working.... :( :(

Prefrably just below the Productname,see picture



[attachment cleanup by admin]

SPABO

Hi,
After further digging into this forum, I found the rigt code to solve this

In my cas I have put this just after the productname, before the productimage ( in default_products.php)


<?php
if (!empty($product->prices['discountAmount'])) {
if (
$this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices))
{
$discount=$this->currency->formatNumber($product->prices['discountAmount']);
$basePrice $this->currency->formatNumber($product->prices['basePrice']);
$total =($discount 100) / $basePrice;
$total round(-$total0);
echo 
"<div class='discountpercent'>Bespaar: ".$total."%!</div>";

}
?>


Topic can be closed now

Rgds
K