写的不是很严谨,欢迎指教。
在function_price 下建了个函数 :
各位根据自己的实际情况进行 修改 吧。。
当然自己还有根据实际情况修改价格显示的方式
再做任何修改前请做好备份!!!!
在function_price 下建了个函数 :
//get sale or special price expires time
function zen_get_promotion_price_time($products_id){
global $db;
//specials
$sql_expires_date = "select expires_date from " . TABLE_SPECIALS . " where products_id = " . $products_id . " and status =1" ;
//echo $sql_expires_date;
$expires_date = $db->Execute($sql_expires_date);
if($expires_date ->RecordCount() > 0){
$specials_date_end = $expires_date->fields['expires_date'];
}
$sql_products_mcate = "select master_categories_id from ". TABLE_PRODUCTS . " where products_id = ". (int)$products_id ;
//echo $sql_products_mcate;
$procuts_mcate = $db->Execute($sql_products_mcate);
$sql_sale1 = "select sale_specials_condition, sale_date_end from " . TABLE_SALEMAKER_SALES . " where sale_categories_all like '%," . $procuts_mcate->fields['master_categories_id'] . ",%' and sale_status = 1 order by sale_id limit 1";
//echo $sql_sale;
$sale1 = $db->Execute($sql_sale1);
if($sale1 -> RecordCount() > 0 ){
if($sale1->fields['sale_specials_condition'] == 1){
if(!$specials_date_end){
return $sale1->fields['sale_date_end'];
}else{
return $specials_date_end;
}
}else{
return $sale1->fields['sale_date_end'];
}
}else{
return $specials_date_end;
}
}
template 下 product_info_display
插入:
<?php
$end_time = zen_get_promotion_price_time((int)$_GET['products_id']). " 00:00:00";
$time_now = date('Y-m-d H:i:s'); //
$left_time = strtotime($end_time)- strtotime($time_now);
// echo $time_now." " . $end_time;
?>
<script language="javascript" type="text/javascript">
var runTime = 0;
function CountDown(){
var nMs = <?php echo $left_time ?> * 1000 - runTime * 1000;
var nD = Math.floor(nMs/(1000*60*60*24));
var nH = Math.floor(nMs/(1000*60*60))%24;
var nM = Math.floor(nMs/(1000*60))%60;
var nS = Math.floor(nMs/1000)%60
if(nH<10){ nH = "0"+nH;}
if(nM<10){ nM = "0"+nM;}
if(nS<10){ nS = "0"+nS;}
//alert(nS);
//document.getElementById('productPrices').innerHTML = nH+":"+nM+":"+nS+" left";
$("#productPrices #time1").html( ((nD > 0) ? nD+((nD>1)? " Days ":" Day ") :"") + nH+":"+nM+":"+nS+" left");
runTime++;
}
window.onload = CountDown;
setInterval("CountDown()",1000);
</script>
再附下css吧:
#productPrices .off{
background: url("../images/time.jpg") no-repeat scroll 0 0 transparent;
color: #FFFFFF;
float: left;
height: 31px;
line-height: 31px;
padding-left: 52px;
width: 71px;
}
#productPrices .productPriceDiscount {
background: url("../images/tbg.jpg") no-repeat scroll right top transparent;
height: 31px;
margin-bottom: 10px;
margin-top:5px;
position: relative;
width: 275px;
font-size:12px;
}
#productPrices .off2 {
color: #FFFFFF;
display: block;
float: left;
height: 35px;
line-height: 30px;
text-align: center;
width: 145px;
}
各位根据自己的实际情况进行 修改 吧。。
当然自己还有根据实际情况修改价格显示的方式
<h2 id="productPrices" class="productGeneral">
<span class="normalprice">$195.14 </span>
<span class="productSpecialPrice">$99.00</span>
<div id="timer_1" class="productPriceDiscount">
<div class="off">49% off</div>
<div id="time1" class="off2">12:46:21 left</div>
</div>
</h2>
再做任何修改前请做好备份!!!!