VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dslove on April 15, 2016, 13:24:22 PM

Title: Adding product thumbnail, name and price to addtocartbar.php
Post by: dslove on April 15, 2016, 13:24:22 PM
Customizing the addtocartbar.php file so the product thumbnail, name and price display next to the Quantity box, I have run into an issue concerning the price display.

<?php echo $product->prices['salesPrice']; ?>

I wish to display only the final sales price, but the above code 1) returns only an integer if the number is round 2) displays a dot(.) instead of a comma(,) as a decimal separator and 3) does not display currency symbol.

I have already tried calling the prices sublayout but the page breaks since calling a sublayout from a sublayout seems to do just that.

Any advice?
Title: Re: Adding product thumbnail, name and price to addtocartbar.php
Post by: Ghost on April 15, 2016, 14:04:01 PM
You can include a sublayout inside a sublayout. Maybe forgot to set currency or product data? This should work:

$currency = CurrencyDisplay::getInstance();
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$currency));


Or you can add just the price div:

$currency = CurrencyDisplay::getInstance();
echo $currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
Title: Re: Adding product thumbnail, name and price to addtocartbar.php
Post by: dslove on April 15, 2016, 14:13:39 PM
Issue solved instantly, thank you Ghost!!! :) :) :)