问: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{
旧
}
效果图:


