> Zencart中文手册 > zen cart判断产品是否免费商品

zen_get_products_price_is_free 函数是判断产品是否是免费的商品,该函数的实现功能其实很简单,主要就是获取产品表products 的product_is_free 字段,如果该字段的值为1说明该产品是属于免费产品。该值的设置是在添加产品的时候有设置。默认该值为0,即不是免费商品。函数的参数为产品的ID值。

函数原型如下,函数定义位于includesfunctionsfunctions_prices.PHP 文件中

 

function zen_get_products_price_is_free($products_id) {
global $db;
$product_check = $db->Execute(“select product_is_free from ” . TABLE_PRODUCTS . ” where products_id = ‘” . (int)$products_id . “‘” . ” limit 1″);
if ($product_check->fields['product_is_free'] == ’1′) {
$the_free_price = true;
} else {
$the_free_price = false;
}
return $the_free_price;
}