News:

Support the VirtueMart project and become a member

Main Menu

how to display two prices

Started by joely666, September 19, 2012, 18:32:28 PM

Previous topic - Next topic

joely666

Hi,

I need to display two prices 'our price' and 'high street price' on the product page. This works fine by using the 'cost price' field as 'high street' and the 'override' field as 'our price'.
A problem arises on certain products when I only want to display 'our price'. Both 'high street' and 'our price' are displayed, and they are the same.

I have tried modifying the code in default_showprices.php to display only 'our price' if the prices are the same: <?php
    
}
    if (
$this->showBasePrice) {
echo $this->currency->createPriceDiv('basePrice''COM_VIRTUEMART_PRODUCT_BASEPRICE'$this->product->prices);
echo $this->currency->createPriceDiv('basePriceVariant''COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT'$this->product->prices);
    }

    if (
$this->priceWithoutTax == $this->salesPrice) {
echo $this->currency->createPriceDiv('priceWithoutTax''Our Price:'$this->product->prices);
} else {

echo $this->currency->createPriceDiv('priceWithoutTax''High street:'$this->product->prices);
    echo 
$this->currency->createPriceDiv('salesPrice''Our Price:'$this->product->prices);
    
  } ?>



Unsurprisingly it didn't work.
If anyone can offer the correct PHP to do this, that would be great. It may well be the case that I am going about this in completely the wrong way in terms of VM configuration, so if anyone can point me in the right direction without having to edit PHP that would be even better.

I'm using Joomla 2.5.6 and VM 2.0.10.

Thanks

stuart.prevos

I have something like this with  RRP and Our Price. I created a custom field for the RRP and then used

$customfield=$field->custom_title;
if ($customfield=="RRP:")
   {
   echo $customfield;
   echo "&nbsp";
   echo $field->display;
  echo "<br>";
}
echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices);


but I guess you could do something like
if ($customfield=="RRP:") && ($customfield<salesprice)
   {
   echo $customfield;
   echo "&nbsp";
   echo $field->display;
  echo "<br>";
}


you can see it here if you like  http://www.vtsdemo.co.uk/tarabooks/top-level/third-class-age-8-9.html

joely666

Thanks. I would like to keep the price entry to the 'Product information' if possible, but I will look at your method if I can't find any other solution.

randomdev

This is what I used in the productdetails override:

if ($this->product->prices['basePrice'] != $this->product->prices['salesPrice']) {
echo $this->currency->createPriceDiv ( 'basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $this->product->prices );
}


So it doesnt display the rrp if the prices are the same.