// 获得商品的规格和属性 $smarty->assign('properties', $properties['pro']); // 商品属性 $smarty->assign('specification', $properties['spe']); // 商品规格 $smarty->assign('attribute_linked', get_same_attribute_goods($properties)); // 相同属性的关联商品 $smarty->assign('related_goods', $linked_goods); // 关联商品 $smarty->assign('goods_article_list', get_linked_articles($goods_id)); // 关联文章 $smarty->assign('recommend_goods', get_recommend_goods('hot')); //获得相关推荐商品 $smarty->assign('fittings', get_goods_fittings(array($goods_id))); // 配件 $smarty->assign('rank_prices', get_user_rank_prices($goods_id, $shop_price)); // 会员等级价格 $smarty->assign('pictures', get_goods_gallery($goods_id)); // 商品相册 //$smarty->assign('bought_goods', get_also_bought($goods_id)); // 购买了该商品的用户还购买了哪些商品 //$smarty->assign('goods_rank', get_goods_rank($goods_id)); // 商品的销售排名 //$smarty->assign('related_cat', get_related_cat($goods['cat_id'])); //$smarty->assign('related_brand', get_related_brand($goods['cat_id'])); //$smarty->assign('top10_brand', get_top10_brand($goods['brand_id'])); //$smarty->assign('top10_category', get_top10($goods['cat_id'])); //$smarty->assign('top10_price', get_top10_price($goods['shop_price'])); //by mike start //组合套餐名 /*$comboTabIndex = array(' ','一', '二', '三','四','五','六','七','八','九','十'); $smarty->assign('comboTab',$comboTabIndex); //组合套餐组
} foreach ($goods_att as $val) { if (!empty($val)) { $sql = "SELECT `attr_price` FROM " . $ecs->table('goods_attr') . " WHERE goods_id='{$goods_id}' AND `goods_attr_id`='{$val}'"; $atr_price += $db->getOne($sql); } } $result['cart_price'] = $result['shop_price_shao'] + $atr_price; //本店售价加上属性价格 $result['is_promote'] = $goods['is_promote']; //$result['shop_price']=$goods_price+$atr_price; $result['promote_start_date'] = $goods['promote_start_date']; $result['promote_end_date'] = $goods['promote_end_date']; $result['user_rank_info'] = get_rank_info($user_id); //$result['user_rank_prices']=get_user_rank_prices($goods_id, $result['shop_price'],$user_id); $result['user_rank_prices'] = get_user_rank_prices($goods_id, $shop_pricr, $user_id, $atr_price, $goods['promote_price']); print_r(json_encode($result)); } /*=====================================ecshop的一些函数方法======================================*/ /** * 获得指定商品的各会员等级对应的价格 * * @access public * @param integer $goods_id * @return array */ function get_user_rank_prices($goods_id, $shop_price, $user_id, $atr_price, $promote_price) { $user_rank = $GLOBALS['db']->getOne("SELECT user_rank FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$user_id}'"); $sql = "SELECT rank_id, IFNULL(mp.user_price, r.discount * {$shop_price} / 100) AS price, r.rank_name, r.discount, r.show_price " . 'FROM ' . $GLOBALS['ecs']->table('user_rank') . ' AS r ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = '{$goods_id}' AND mp.user_rank = r.rank_id "; $res = $GLOBALS['db']->query($sql);
// 获得商品的规格和属性 $smarty->assign('properties', $properties['pro']); // 商品属性 $smarty->assign('specification', $properties['spe']); // 商品规格 $smarty->assign('attribute_linked', get_same_attribute_goods($properties)); // 相同属性的关联商品 $smarty->assign('related_goods', $linked_goods); // 关联商品 $smarty->assign('goods_article_list', get_linked_articles($goods_id)); // 关联文章 $smarty->assign('fittings', get_goods_fittings(array($goods_id))); // 配件 $smarty->assign('rank_prices', get_user_rank_prices($goods_id, $shop_price)); /*甜心添加*/ $rank_prices = get_user_rank_prices($goods_id, $shop_price); $user_prices = ""; foreach ($rank_prices as $k => $v) { if ($_SESSION['user_rank'] == $k) { $user_prices = $v; } } $smarty->assign('user_prices', $user_prices); /*甜心添加*/ //甜心添加判断该商品是否被收藏过 $is_collect = 0; $user_id = $_SESSION['user_id']; $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE user_id = '{$user_id}' and goods_id='{$goods_id}'"; $is_collect = $GLOBALS['db']->getRow($sql); if (!empty($is_collect)) { $smarty->assign('is_collect', 1);
<?php /** * 购物车更新商品价格 */ define('IN_ECS', true); require '../includes/init.php'; //require('../includes/lib_goods.php'); $goods_id_arr = isset($_REQUEST['goods_id_arr']) ? trim($_REQUEST['goods_id_arr']) : 0; $user_id = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : 0; $sql = "SELECT g.goods_id,g.shop_price,g.is_promote,g.promote_price,g.promote_start_date,g.promote_end_date FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete = '0' AND is_on_sale = '1' and g.goods_number >0 AND g.goods_id IN ({$goods_id_arr})"; $row = $GLOBALS['db']->getAll($sql); $user_rank_name = get_rank_info($user_id); $time = time(); foreach ($row as $k => $value) { $user_rank_prices = get_user_rank_prices($value['goods_id'], $value['shop_price'], $user_id); foreach ($user_rank_prices as $rank_prices_value) { if ($user_rank_name['rank_name'] == $rank_prices_value['rank_name']) { if ($value['is_promote'] == 1) { //if($value['promote_price']<$rank_prices_value['price']&&$value['promote_start_date']<=$time&&$value['promote_end_date']>$time){ //$row[$k]['shop_price']=str_replace('¥','',$value['promote_price']); //}else{ $row[$k]['shop_price'] = str_replace('¥', '', $rank_prices_value['price']); //} } else { $row[$k]['shop_price'] = str_replace('¥', '', $rank_prices_value['price']); } } } } print_r(json_encode($row));