News:

Support the VirtueMart project and become a member

Main Menu

Add discount price in virtuemart products module

Started by pm4698, October 04, 2014, 23:06:37 PM

Previous topic - Next topic

pm4698

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

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

pm4698

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>