zencart 促销 特价 显示倒计时

写的不是很严谨,欢迎指教。  
 
 
在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>
 
 
再做任何修改前请做好备份!!!!  

 





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值