帝国CMS怎么调用购物车商品数量
帝国cms模板调用购物车商品数量和总价的方法,一起来看看吧:
代码如下:
getMessage(); } /**计算商品价格*/ function this_price($id){ $connect = connectDB(); $query = "select price from phome_ecms_news where id = ".$id; if(!$connect){ throw new Exception("数据库链接不成功,请检查!"); } if(!$result = $connect -> query($query)){ throw new Exception("查询失败!"); } $row = $result -> fetch_assoc(); return $row['price']; } /**链接数据库*/ function connectDB(){ global $phome_db_server,$phome_db_username,$phome_db_password,$phome_db_dbname,$phome_db_char; $connect = new mysqli($phome_db_server,$phome_db_username,$phome_db_password,$phome_db_dbname); $connect -> query("set Names ".$phome_db_char); return $connect; } /**显示结果Js*/ function displayResultJs($totalPrice,$totalProducts){ return "您的购物车中有 {$totalProducts} 件商品,总计金额 ¥{$totalPrice}元。"; } ?>
点击查看 结算>>