教你如何显示 会员等级对应的商品价格

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

1.建三个等级会员

2.lib_goods.php 中查找{
$type_array[$key] = array();
}
}

..........................
..........................
/**
* 获得商品的详细信息
*
* @accesspublic
* @paraminteger$goods_id
* @returnvoid
*/

省略号部份用以下代码替换


  1. if( $_SESSION[user_rank] == 0 ){
  2. $user_rank=6;
  3. }
  4. else{
  5. $user_rank = $_SESSION[user_rank] ;
  6. }

  7. //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
  8. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, g.give_integral,mp.user_rank as userrank,r.rank_name, r.discount, IFNULL(mp.user_price, r.discount*g.shop_price/100) AS rank_price,' .
  9. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
  10. "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " .
  11. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  12. "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
  13. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$user_rank' ".
  14. "LEFT JOIN " . $GLOBALS['ecs']->table('user_rank') . " AS r ".
  15. "ON r.rank_id=$user_rank";
  16. $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
  17. $type_merge = array_unique($type_merge);
  18. $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
  19. $sql .= ' ORDER BY g.sort_order, g.last_update DESC';
  20. $result = $GLOBALS['db']->getAll($sql);
  21. foreach ($result AS $idx => $row)
  22. {
  23. if ($row['promote_price'] > 0)
  24. {
  25. $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
  26. $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
  27. }
  28. else
  29. {
  30. $goods[$idx]['promote_price'] = '';
  31. }
  32. $goods[$idx]['id']= $row['goods_id'];
  33. $goods[$idx]['name']= $row['goods_name'];
  34. $goods[$idx]['rank_name'] = $row['rank_name'];
  35. $goods[$idx]['discount'] = $row['discount'];
  36. $goods[$idx]['brief']= $row['goods_brief'];
  37. $goods[$idx]['brand_name']= isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
  38. $goods[$idx]['goods_style_name']= add_style($row['goods_name'],$row['goods_name_style']);
  39. $goods[$idx]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ?
  40. sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
  41. $goods[$idx]['short_style_name']= add_style($goods[$idx]['short_name'],$row['goods_name_style']);
  42. $goods[$idx]['market_price'] = price_format($row['market_price']);
  43. $goods[$idx]['shop_price']= price_format($row['shop_price']);
  44. $goods[$idx]['rank_price']= price_format($row['rank_price']);
  45. $goods[$idx]['give_integral']= $row['give_integral'];
  46. $goods[$idx]['thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
  47. $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
  48. $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);




  49. if (in_array($row['goods_id'], $type_array['best']))
  50. {
  51. $type_goods['best'][] = $goods[$idx];
  52. }
  53. if (in_array($row['goods_id'], $type_array['new']))
  54. {
  55. $type_goods['new'][] = $goods[$idx];
  56. }
  57. if (in_array($row['goods_id'], $type_array['hot']))
  58. {
  59. $type_goods['hot'][] = $goods[$idx];
  60. }
  61. }
  62. }
  63. return $type_goods[$type];

  64. }
复制代码


3。在模版 文件中 (如: recommend_best.lbi)
<!-- {if $show_marketprice} -->
{$lang.market_price}<span class="market">{$goods.market_price}</span><br />
<!-- {/if} -->

下面添加
添加

{$goods.rank_name}{$goods.rank_price} <br>


这样就完成了。
在没有登陆的时候显示普通会员价,登陆之后就显示会员对应的等级和价格。

回答:
不需要做任何修改,EC本来就有这个功能的啊!

会员登陆后 显示等级对应的商品价格,ECSHOP 管理中心 - 会员等级 --显示价格点成红叉,就可以实现了

不行的。。。。。。。。。。。。。。

嗯~我用 2.6.2 版本來就有這個功能ㄚ~
現正常使用沒問題~~會對應~~

不行呀,哥们,会员等级与价格根本就不对应,相应的会员等级,根本就不显示价格,

没有解决 调用价格的问题, 请LZ再解释解释, 谢谢

不错,,,,,,,,,

谢谢学习了

不能显示等级的,只能显示价格!

1.建三个等级会员
23307
2.lib_goods.php 中查找{
$type_array[$key] = array();
}
}

..........................
........................ ...
long1689 发表于 2009-5-10 05:18

这个不能显示等级,只能显示当前等级价格,怎么改显示等级+价格呢?谢谢

留个印,研究

如何实现等级3的可以显示等级2的价格。同时显示

<!-- {if $show_marketprice} -->
{$lang.market_price}<span class="market">{$goods.market_price}</span><br />
<!-- {/if} -->

下面添加
添加

{$goods.rank_name}{$goods.rank_price} <br>


这样就完成了。


世博礼品

世博纪念品

世博会礼品


我想实现等级3的可以显示等级2的价格,等级2不能看等级3的价格