联系电话:0755-27515592
最新动态:

zencart教程

zencart判断产品是否为新品,特价

点击数:11732015-07-27 10:23:42 来源: 外贸网站建设,深圳外贸网站建设,深圳网站建设,外贸商城网站制作-亿恩科技

新闻摘要:对于那些想做二次开发的人,为点帮助了。 问:zencart 是如何判断产品是否为新品,特价。 答: 1.在includes/functions/extra_functions/my_products.p

最近忙,都没有时间打理博客。今儿找到一篇文章,对于那些想做二次开发的人,为点帮助了。

问:zencart 是如何判断产品是否为新品,特价。

答:

1.在includes/functions/extra_functions/my_products.php 加入下面的代码。

=======================

<?php
function my_zen_get_products_price_is_specials($product_id){
        global $db;
        $specials = $db->Execute("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status='1'");
        if ($specials->RecordCount() > 0) {
                return true;
         } else {
                return false;
         }
        }
function my_zen_get_products_price_is_new($product_id){
        if(SHOW_NEW_PRODUCTS_LIMIT == 0)
                return true;
        global $db;
        $product = $db->Execute("select products_date_added from " . TABLE_PRODUCTS . " where  products_id = '" . (int)$product_id . "' and products_status='1'");
        if($product->RecordCount()>0){
                $now=time();
                $mintime=$now-SHOW_NEW_PRODUCTS_LIMIT*86400;
                if(strtotime($product->fields['products_date_added'])>$mintime){
                        return true;
                }else{
                        return false;
                }
        }else{
                return false;
        }
}
?>

=========================

2。任何地方都可以使用
判断一个产品是否有特价
if(my_zen_get_products_price_is_specials($product_id)){

}else{

}
判断一个产品是新产品
如果后台没有设置都是新产品 
if(my_zen_get_products_price_is_new($product_id)){

}else{

}

效果图:

【责任编辑:(Top) 返回页面顶端
贴心
全国7×24小时客服热线
安全
病毒杀除率高于99%
稳定
网站可用性高于99.9%
实力
服务68家上市企业及集团公司
亿恩科技手机站
关注亿恩科技微信

亿恩科技—企业信息化一站式服务专家


Copyright © 2008- 深圳市亿恩科技有限公司版权所有 粤ICP备15056041号

联系我们 | 常见问题 | 在线留言 | 支付方式 | 软件开发 | 我的观点 | 资质荣誉 | 服务流程