ecshop quotation.php显示会员等级价格

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

在ecshop2.6.2中。quotation.php报价单打印存在ecshop会员等级的价格问题.

比如在后台设置注册会员折扣为80.录入产品的时候,如果按默认的-1.那么本店价格100的产品,注册会员应该是80.如果手动录入,会员价格是85.在报价格单里面还是按照100*0.8来显示。这样的话,手动输入的 注册会员价格就失效了。

$user_rank = calc_user_rank($user_rank, $rank_point);是用来处理等级价格的,还真不好用,他却忘记了考虑手动录入的等级价格。

首先,编写会员等级处理价格函数.根据产品ID,会员等级ID.

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;

}

在报价单列表页面,需要加入会员等级ID和等级名称。

$smarty->assign('urank',$_SESSION['user_rank']);

$smarty->assign('urank_n',$db -> getOne("select rank_name from ".$ecs->table('user_rank')." where rank_id = ".$_SESSION['user_rank']));



其次,处理报价单会员等级价格。

foreach ($goods_list as $k => $v){

$goods_list[$k]['rank'] = get_user_rank_prices($v['goods_id'], $v['shop_price']);

}

修改data/quotation_print.html目录下,打印模板。

增加头部.

<tr>

<th width="35%">{$lang.goods_name}</th>

<th width="10%"> 产品编号</th>

<th>图片</th>

<th>{$lang.goods_category}</th>

<!--{if $cfg.use_storage and $cfg.show_goodsnumber}-->

<th>{$lang.goods_inventory}</th>

<!-- {/if} -->

<th>本店价格</th>

<!--{foreach from=$extend_price key=key name = n item=ext_price}-->

{if $ext_price == $urank_n}

<th>{$ext_price}</th>

{/if}

<!--{/foreach}-->

</tr>

<!--{foreach from=$goods_list item=goods}-->

<tr>

<td><a href="goods.php?id={$goods.goods_id}">{$goods.goods_name}</a></td>

<td>{$goods.goods_sn}</td>

<td><img src="{$goods.goods_thumb}" width="40" height="40"></td>

<td>{$goods.goods_category}</td>

<!--{if $cfg.use_storage and $cfg.show_goodsnumber}-->

<td>{$goods.goods_number}</td>

<!-- {/if} -->

<td>{$goods.shop_price}</td>

<!--{foreach from=$goods.rank item=ext_rank}-->



{if $urank_n == $ext_rank.rank_name}

<td>{$ext_rank.price}</td>

{/if}

<!--{/foreach}-->

</tr>

<!--{/foreach}-->

通过{if $urank_n == $ext_rank.rank_name}来判断对应等级的价格.

通过{if $ext_price == $urank_n}来判断头部对应价格的名称.