服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

magento给specail产品展示页面添加倒计时功能

时间:2015-07-14 13:39来源:未知 作者:最模板 点击:
近日,我们依据客户的要求,修改了specail 产品展示页面,使其可以有一个简单漂亮的倒计时的功能,此版本支持MAGENTO1.9.1且兼容市面绝大多数的浏览器,用最简洁的代码给用户最好了的

magento给specail产品展示页面添加倒计时功能

 

近日,我们依据客户的要求,修改了specail 产品展示页面,使其可以有一个简单漂亮的倒计时的功能,此版本支持MAGENTO1.9.1且兼容市面绝大多数的浏览器,用最简洁的代码给用户最好了的体验。

修改template\catalog\product\view\type\default.phtml文件为

<?php $_product = $this->getProduct() ?>

<?php echo $this->getPriceHtml($_product) ?>

<!--time-->
<?php if($specialPriceToDate = $_product->getSpecialToDate()):?>
	<div class="flashsale">
	<div class="" style="float:left"><img src="/<?php echo $this->getSkinUrl('images/countdown.png'); ?>" width="35px"/></div>	<div class="clock">
		<span id="time-over" class="timer">
			<span class="day_count" id="day_count_<?php echo $_product->getId();?>"> </span><span class="day">days</span>
			<span class="day_seconds">
				<span id="hour_<?php echo $_product->getId();?>"> </span>:
				<span id="minute_<?php echo $_product->getId();?>"> </span>:
				<span id="second_<?php echo $_product->getId();?>"> </span>
			</span>
		</span>
		</div>
	</div>
 
	
 
	<script type="text/j-avascript">
		countDown("<?php echo date("Y/m/d H:i:s",strtotime($specialPriceToDate))?>","day_count_<?php echo $_product->getId();?>","hour_<?php echo $_product->getId();?>","minute_<?php echo $_product->getId();?>","second_<?php echo $_product->getId();?>");
		function countDown(time,day_elem,hour_elem,minute_elem,second_elem){        
            var end_time = new Date(time).getTime(), //-1    
			sys_second = (end_time-new Date().getTime())/1000;
            var timer = setInterval(function(){
                if (sys_second > 1) {
                    sys_second -= 1;
                    var day = Math.floor((sys_second / 3600) / 24);
                    var hour = Math.floor((sys_second / 3600) % 24);
                    var minute = Math.floor((sys_second / 60) % 60);
                    var second = Math.floor(sys_second % 60);
                    document.getElementById(day_elem).innerHTML = day;
                    document.getElementById(hour_elem).innerHTML = hour<10?"0"+hour:hour;
                    document.getElementById(minute_elem).innerHTML = minute<10?"0"+minute:minute;
                    document.getElementById(second_elem).innerHTML = second<10?"0"+second:second;
                } else {
                    document.getElementById("time-over").innerHTML = "time over" ;
                    clearInterval(timer);
                }
            }, 1000);
        }
	</script>
	
	 
 

<?php endif;?>
			
<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable()): ?>
        <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
    <?php else: ?>
        <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>
<?php endif; ?>

<?php echo $this->getChildHtml('product_type_data_extra') ?>

则可以实现相关的倒计时special price功能

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------