VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: pm4698 on October 04, 2014, 23:06:37 PM

Title: Add discount price in virtuemart products module
Post by: pm4698 on October 04, 2014, 23:06:37 PM
Hello there.

I think title says it all.

How to add discount price to virtuemart products module?

I tried several stuff, with no result

Virtuemart: 2.6.10, joomla 2.5.x
Title: Re: Add discount price in virtuemart products module
Post by: jenkinhill on October 04, 2014, 23:24:57 PM
All prices can be displayed in the VM default products module. If you are using a third party module or commercial template/theme then you should compare the code with the default module template.  Or ask the template developer.
Title: Re: Add discount price in virtuemart products module
Post by: pm4698 on October 09, 2014, 15:32:51 PM
Ok i added a custom code that first compares basePrice and SalesPrice and if not equal, then i calculate discount in a variable as percentage and echo. Here is  this code:

$base = $product->prices['basePrice'];
                                $sale = $product->prices['salesPrice'];
                                $discount = abs($base - $sale);
                                $discountPercent = round((100*$discount)/$base,0);
                                if($discountPercent > 0){
                                  ?>
                    <div style="width:70px;">
                        <div class="PricediscountAmount">
        <?php
                         echo  
'<span class="PricediscountAmount">'.$discountPercent.''.'</span>';
?>

                        </div>
                    </div>