当前位置: 首页 > 购物流程
商品列表
商品名称 属性 市场价 本店价 购买数量 小计 操作
购物金额小计 ¥0.00元,比市场价 ¥0.00元 节省了 ¥0.00元 (0)
continue checkout
sset($cart_favourable[$favourable['act_id']]); } } /** * 添加优惠活动(赠品)到购物车 * @param int $act_id 优惠活动id * @param int $id 赠品id * @param float $price 赠品价格 */ function add_gift_to_cart($act_id, $id, $price) { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('cart') . " (" . "user_id, session_id, goods_id, goods_sn, goods_name, market_price, goods_price, ". "goods_number, is_real, extension_code, parent_id, is_gift, rec_type ) ". "SELECT '$_SESSION[user_id]', '" . SESS_ID . "', goods_id, goods_sn, goods_name, market_price, ". "'$price', 1, is_real, extension_code, 0, '$act_id', '" . CART_GENERAL_GOODS . "' " . "FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = '$id'"; $GLOBALS['db']->query($sql); } /** * 添加优惠活动(非赠品)到购物车 * @param int $act_id 优惠活动id * @param string $act_name 优惠活动name * @param float $amount 优惠金额 */ function add_favourable_to_cart($act_id, $act_name, $amount) { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('cart') . "(" . "user_id, session_id, goods_id, goods_sn, goods_name, market_price, goods_price, ". "goods_number, is_real, extension_code, parent_id, is_gift, rec_type ) ". "VALUES('$_SESSION[user_id]', '" . SESS_ID . "', 0, '', '$act_name', 0, ". "'" . (-1) * $amount . "', 1, 0, '', 0, '$act_id', '" . CART_GENERAL_GOODS . "')"; $GLOBALS['db']->query($sql); } /** * 取得购物车中某优惠活动范围内的总金额 * @param array $favourable 优惠活动 * @return float */ function cart_favourable_amount($favourable) { /* 查询优惠范围内商品总额的sql */ $sql = "SELECT SUM(c.goods_price * c.goods_number) " . "FROM " . $GLOBALS['ecs']->table('cart') . " AS c, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE c.goods_id = g.goods_id " . "AND c.session_id = '" . SESS_ID . "' " . "AND c.rec_type = '" . CART_GENERAL_GOODS . "' " . "AND c.is_gift = 0 " . "AND c.goods_id > 0 "; /* 根据优惠范围修正sql */ if ($favourable['act_range'] == FAR_ALL) { // sql do not change } elseif ($favourable['act_range'] == FAR_CATEGORY) { /* 取得优惠范围分类的所有下级分类 */ $id_list = array(); $cat_list = explode(',', $favourable['act_range_ext']); foreach ($cat_list as $id) { $id_list = array_merge($id_list, array_keys(cat_list(intval($id), 0, false))); } $sql .= "AND g.cat_id " . db_create_in($id_list); } elseif ($favourable['act_range'] == FAR_BRAND) { $id_list = explode(',', $favourable['act_range_ext']); $sql .= "AND g.brand_id " . db_create_in($id_list); } else { $id_list = explode(',', $favourable['act_range_ext']); $sql .= "AND g.goods_id " . db_create_in($id_list); } /* 优惠范围内的商品总额 */ return $GLOBALS['db']->getOne($sql); } ?>