让ecshop首页的价格显示对应的等级名称和价格
2009-09-04 11:36 来源:www.chinab4c.com 作者:ecshop专家
1:增加取会员等级价格的函数
function get_user_rank_prices($goods_id, $shop_price)
{
$sql = "SELECT rank_id, IFNULL(mp.user_price, r.discount * $shop_price / 100) AS price, r.rank_name, r.discount " .
'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 " .
"WHERE r.show_price = 1 OR r.rank_id = '$_SESSION[user_rank]'";
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$arr[$row['rank_id']] = array(
'rank_name' => htmlspecialchars($row['rank_name']),
'price' => price_format($row['price']));
}
return $arr;
}
2:修改index.php
$best = get_recommend_goods('best');
$new = get_recommend_goods('new');
$hot = get_recommend_goods('hot');
if($best){
foreach($best as $k => $v){
$up = get_user_rank_prices($v['id'],$v['shopprice']);
if(in_array($_SESSION[user_rank], array_keys($up))){
$best[$k]['shop_price'] = $up[$_SESSION[user_rank]][rank_name].":".$up[$_SESSION[user_rank]][price];
}
}
}
if($new){
foreach($new as $k => $v){
$up = get_user_rank_prices($v['id'],$v['shopprice']);
if(in_array($_SESSION[user_rank], array_keys($up))){
$new[$k]['shop_price'] = $up[$_SESSION[user_rank]][rank_name].":".$up[$_SESSION[user_rank]][price];
}
}
}
if($hot){
foreach($hot as $k => $v){
$up = get_user_rank_prices($v['id'],$v['shopprice']);
if(in_array($_SESSION[user_rank], array_keys($up))){
$hot[$k]['shop_price'] = $up[$_SESSION[user_rank]][rank_name].":".$up[$_SESSION[user_rank]][price];
}
}
}
$smarty->assign('best_goods', $best ); // 推荐商品
$smarty->assign('new_goods', $new); // 最新商品
$smarty->assign('hot_goods', $hot); // 热点文章
最近更新
常用插件
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...