Remove discounted price from product layout Virtuemart

Amanda Watson
Amanda Watson used Ask the Experts™
on
Hi,
On my shop here
http://webfd.omega.studiocoast.com.au/index.php?option=com_virtuemart&Itemid=75&vmcchk=1&Itemid=75

I have some products that have a discounted price and some that don't, however the ones that have no discount still show the line (full price - $0.00)
How can I make this not show if there is no discount applied to the product?
Thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello!

You need to edit the proper tpl.php files in order to tweak VirtueMart the way you want. Here's what you do:

Hope this helps!

Cynthia



1. Download a copy of the /components/com_virtuemart to your local machine.
2. Open /components/com_virtuemart/themes/default/templates/common/price.tpl.php
3. Look for the following code snippet (begins around line 12):

<?php
// DISCOUNT: Show old price!
if(!empty($discount_info["amount"])) {
	?>
	<span class="product-Old-Price">
		<?php echo $CURRENCY_DISPLAY->getFullValue($undiscounted_price); ?></span>
	
	<br/>
	<?php
}
?>

4. Now comment out that section so that it looks like this:

/*
<?php
// DISCOUNT: Show old price!
if(!empty($discount_info["amount"])) {
	?>
	<span class="product-Old-Price">
		<?php echo $CURRENCY_DISPLAY->getFullValue($undiscounted_price); ?></span>
	
	<br/>
	<?php
}
?>
*/

5. Also in this file, look for the following code (about line 35 or so):

<?php
// DISCOUNT: Show the amount the customer saves
if(!empty($discount_info["amount"])) {
	echo "<br />";
	echo $VM_LANG->_('PHPSHOP_PRODUCT_DISCOUNT_SAVE').": ";
	if($discount_info["is_percent"]==1) {
		echo $discount_info["amount"]."%";
	}
	else {
		echo $CURRENCY_DISPLAY->getFullValue($discount_info["amount"]);
	}
}
?>

6. Comment it out, like you did with the previous code snippet. Like this:

/*
<?php
// DISCOUNT: Show the amount the customer saves
if(!empty($discount_info["amount"])) {
	echo "<br />";
	echo $VM_LANG->_('PHPSHOP_PRODUCT_DISCOUNT_SAVE').": ";
	if($discount_info["is_percent"]==1) {
		echo $discount_info["amount"]."%";
	}
	else {
		echo $CURRENCY_DISPLAY->getFullValue($discount_info["amount"]);
	}
}
?>
*/

7. Save the file.

8. Make a backup of the ORIGINAL unedited file.

9. Upload your edited file to /components/com_virtuemart/themes/default/templates/common/ on your server.

10. Test your results in your browser.

Open in new window

Amanda WatsonWeb Developer

Author

Commented:
Hi Cynthia,
Thanks for such a great detailed explanation.
I was just wondering, will this remove it completely, or will the prices that have discounts still show the discounted and full price?
It will remove it completely.

Best,

Cynthia
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Amanda WatsonWeb Developer

Author

Commented:
I really don't want to remove it completely. I was hoping to have it show when there is a discounted price to show, and I don't want it to show if the full price is all there is to show??
Amanda WatsonWeb Developer

Author

Commented:
Just an interesting note, but on this page here:

http://webfd.omega.studiocoast.com.au/index.php?flt1[0]=0&flt2[0]=0&vm_mnuf[0]=0&fr_price=45&to_price=2500&option=com_catfiltering&task=search

It is using a slightly different layout, but the discounted price only shows when there is one to show??

I can show the files used for that layout here

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26555744.html

So why is it in my virtuemart layout they want to show all the time, but in this layout they don't?
Hi snowball77,

The code need a condition  if... esle
So compare both page and search for "if" you will see existing conditions and you will be able to find the missing condition.

Use winmerge application to compare both page or upload both page so we can find the condition.


Amanda WatsonWeb Developer

Author

Commented:
I am not sure which code I need to check lenamtl.

This page here price.tpl.php in themes/defautl/templates/common/  has got some if statements commented out, but when I uncomment them the page goes blank..

Is this what you mean?
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>

<?php
// User is not allowed to see a price or there is no price
if( !$auth['show_prices'] || !isset($price_info["product_price_id"] )) {
	
	$link = $sess->url( $_SERVER['PHP_SELF'].'?page=shop.ask&amp;product_id='.$product_id.'&amp;subject='. urlencode( $VM_LANG->_('PHPSHOP_PRODUCT_CALL').": $product_name") );
	echo vmCommonHTML::hyperLink( $link, $VM_LANG->_('PHPSHOP_PRODUCT_CALL') );
}
?>

<?php
if( !empty( $price_info["product_price_id"] )) { ?>

      <span class="productPrice">

            <?php echo $CURRENCY_DISPLAY->getFullValue($base_price) ?>

            <?php echo $text_including_tax ?>

<?php echo " ".$product_unit; ?>
      </span>

<?php
}
echo $price_table;
?>

<?php
// DISCOUNT: Show old price!
//if(!empty($discount_info["amount"])) {
//	print_r ($discount_info);
	?><p class="old">FULL PRICE
	<span class="product-Old-Price">
<?php echo $CURRENCY_DISPLAY->getFullValue($undiscounted_price); ?></span></p>
	<?php
//}
?>

<?php
/* DISCOUNT: Show the amount the customer saves
if(!empty($discount_info["amount"])) {
	echo "<br />";
	echo $VM_LANG->_('PHPSHOP_PRODUCT_DISCOUNT_SAVE').": ";
	if($discount_info["is_percent"]==1) {
		echo $discount_info["amount"]."%";
	}
	else {
		echo $CURRENCY_DISPLAY->getFullValue($discount_info["amount"]);
	}
}*/
?>

Open in new window

Amanda WatsonWeb Developer
Commented:
Ok got it,

I need to change line 29 - 38 to this

<?php
// DISCOUNT: Show old price!
if(!empty($discount_info["amount"])) {
//print_r ($discount_info);
      ?><p class="old">FULL PRICE
      <span class="product-Old-Price">
<?php echo $CURRENCY_DISPLAY->getFullValue($undiscounted_price); ?></span></p>
      <?php
}
?>

I had to uncomment the if statement

Thanks girls
yes this make sens!
sorry I was very busy during the day and didn't have time to came back earlier.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial