ECSHOP实现首页读取会员等级和价格

时间:2024年02月04日

/

来源:网络

/

编辑:佚名

实现在首页读取会员等级和价格的方法
1:在   includes/lib_goods.php 中       查找
复制代码
{
$type_array[$key] = array();
}
}

复制代码
用下面的代码替换
复制代码
/**
* 获得商品的详细信息
*
* @access public
* @param integer $goods_id
* @return void
*/
if( $_SESSION[user_rank] == 0 ){
$user_rank=6;
}
else{
$user_rank = $_SESSION[user_rank] ;
}
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$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,’ .
“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 = ‘$user_rank’ “.
“LEFT JOIN ” . $GLOBALS['ecs']->table(’user_rank’) . ” AS r “.
“ON r.rank_id = $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’;
$result = $GLOBALS['db']->getAll($sql);
foreach ($result AS $idx => $row)
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ”;
}
else
{
$goods[$idx]['promote_price'] = ”;
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['rank_name'] = $row['rank_name'];
$goods[$idx]['discount'] = $row['discount'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ”;
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['rank_price'] = price_format($row['rank_price']);
$goods[$idx]['give_integral'] = $row['give_integral'];
$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = build_uri(’goods’, array(’gid’ => $row['goods_id']), $row['goods_name']);
if (in_array($row['goods_id'], $type_array['best']))
{
$type_goods['best'][] = $goods[$idx];
}
if (in_array($row['goods_id'], $type_array['new']))
{
$type_goods['new'][] = $goods[$idx];
}
if (in_array($row['goods_id'], $type_array['hot']))
{
$type_goods['hot'][] = $goods[$idx];
}
}
}
return $type_goods[$type];
}
复制代码
2:在首页要调用的库文件中 (如: recommend_best.lbi)
找到
<!– {if $show_marketprice} –>
{$lang.market_price}<span>{$goods.market_price}</span><br />
<!– {/if} –>
下面添加
{$goods.rank_name}{$goods.rank_price} <br>
这样,在没有登陆的时候显示 普通会员价,登陆之后就显示会员对应的等级和价格。
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。