Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display "You save n%"


Guest

Recommended Posts

Posted

I am wondering how to get my pages to display someting like

 

list price $100

our price $50

you save 50%

 

Thanks in advance!

Posted

if ($new_price = tep_get_products_special_price($product_info_values['products_id'])) {

$list_price = '<s>' . $currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) . '</s>';

$our_price = '<span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id'])) . '</span>';

//get the list price and special price and then display the savings

$no_savings = substr(($currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))), 1);

$no_savings = $no_savings + 0.0;

$now_savings = substr(($currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id']))), 1);

$now_savings = $now_savings + 0.0;

$savings = (($now_savings / $no_savings) * 100);

$savings = round($savings);

 

} else {

$list_price = $currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']));

}?>

<center>List Price: <? echo $list_price; ?><br>

Our Price: <? echo $our_price; ?><br>

You Save: <? echo $savings. "%"; ?>

 

I put this code into the products_info page so that it displays just under the product picture. Works wonderfully!

Posted

Do you have a URL so we can see how it looks ?

 

Regards

The_Bear

Posted

Linda's SEC does this also.

[no external urls in signatures please, kthanks]

Posted

Very cool :)

[no external urls in signatures please, kthanks]

Posted
how to use this code?

 

i past to product_info page and got a lot errors

 

 

thanks

 

Replace everything between

 

<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info_values['products_image']) . '">' . tep_image(DIR_WS_IMAGES . $product_info_values['products_image'], $product_info_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>

</noscript><p align="right">

 

and

 

</table><p><?php echo stripslashes($product_info['products_description']); ?></p>

 

You should be replacing:

 

</td>

</tr>

<?php

}

?>

 

with all of this code:

 

<p align="right">

 

<?php

}

if ($new_price = tep_get_products_special_price($product_info_values['products_id'])) {

$list_price = '<s>' . $currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) . '</s>';

$our_price = '<span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id'])) . '</span>';

//get the list price and special price and then display the savings

$no_savings = substr(($currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))), 1);

$no_savings = $no_savings + 0.0;

$now_savings = substr(($currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id']))), 1);

$now_savings = $now_savings + 0.0;

$savings = (($now_savings / $no_savings) * 100);

$savings = round($savings);

 

} else {

$list_price = $currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']));

}?>

<center>List Price: <? echo $list_price; ?><br>

Our Price: <? echo $our_price; ?><br>

You Save: <? echo $savings. "%"; ?>

</td>

</tr>

 

I think that should take care of your problems.

NOTE: this only works IF you have made a special price for your product. I don't have it configured so that your page will still work if you do not have a special price for your product.

Posted

Thank you for your reply!

 

this mod great!

 

the only thing is just what your said it only works with special product.

 

i think if let this work with all of products, we have to add a new table in DB, and add some new lines in admin/categories.php and product_info.php

 

Anybody got some ideas with this?

 

sean

Posted

I think it may be as simple as adding another column in the products table, perhaps something called products_our_price.

 

http://www.oscommerce.com/community/contributions,1158

 

This contribution tells you how to add the new field.

 

The rest of the work would involve modifying the query in products_info to include the new field. If you know a little php and mysql you should be able to figure this out.

 

Good luck!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...