帝国CMS调用购物车商品数量及总价
发布时间:2022-06-28 13:43 所属栏目:61 来源:互联网
导读:帝国CMS调用购物车商品数量和总价 ?php /** * 根据Cookie值对购物车商品数量和总价格调用 */ require(class/connect.php); $totalProducts = 0; //购物车商品总数 $totalPrice = 0.0; //购物车商品总价 // |77,243|2!|77,237|3! $cookieString = explode(!,$
帝国CMS调用购物车商品数量和总价 <?php /** * 根据Cookie值对购物车商品数量和总价格调用 */ require("class/connect.php"); $totalProducts = 0; //购物车商品总数 $totalPrice = 0.0; //购物车商品总价 // |77,243|2!|77,237|3! $cookieString = explode("!",$_COOKIE['zeuqcmybuycar']); /**计算商品价格*/ 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;//开源软件:phpfensi.com } /**显示结果Js*/ function displayResultJs($totalPrice,$totalProducts){ return "<div class='car'>您的购物车中有 {$totalProducts} 件商品,总计金额 ¥{$totalPrice}元。<br />点击查看 <a href='/e/ShopSys/buycar/'>结算>></a> </div>"; } ?>。 (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读