在首页显示特定某一个会员等级的价格,应该怎么解决啊?

2016-07-07 15:02 来源:www.chinab4c.com 作者:ecshop专家

比如网站的会员等级分为三个等级,如果只想在首页那里显示某一个等级会员的价格,代码应该如何写呀?本人对PHP不是很了解,望各位高手指一下!谢谢!

回答:
直接取得user_rank里面的等级ID来判断.

等级会员价格在ecs_member_price 里的user_price,我已精品推荐为例说一下,我也是小菜鸟,希望大家多多指教,在lib_goods.php里找到get_recommend_goods($type = '', $cats = '')这个函数找到取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_desc ,g.goods_id, g.goods_name,g.goods_number , g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
"promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd" .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank ='$_SESSION[user_rank]' ";
$type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
$type_merge = array_unique($type_merge);
$sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
$sql .= ' ORDER BY g.sort_order, g.last_update DESC';
改为:
取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_desc ,g.goods_id, g.goods_name,g.goods_number , g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
"promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd , mp.user_price" .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank =2 ";
$type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
$type_merge = array_unique($type_merge);
$sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
$sql .= ' ORDER BY g.sort_order, g.last_update DESC';

这里面如要改动两个地方:一是增加mp.user_price,这个是会员等级价格,而是将 mp.user_rank = '$_SESSION[user_rank]'改为 mp.user_rank = 2,2是会员和等级的id,ec默认是3个等级,

找到$goods[$idx]['shop_price']= price_format($row['shop_price']);
在下面加入 $goods[$idx]['user_price']= price_format($row['user_price']);
最后就是在模板相应位置调用就可以,找到recommend_best.lbi加入 {$goods.user_price}即可,多谢大家指教

复杂的……