您的位置:首页 > 运维架构

ecshop中实现不同等级的会员显示不同的商品价格

2014-03-20 17:56 288 查看
1.建三个等级会员

2.upload/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];

}3。在模版 文件中 (如:upload/themes/default/library/goods_list.lbi)

         <!-- {if $show_marketprice} -->

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

        <!-- {/if} -->

下面添加

添加 

{$goods.rank_name}{$goods.rank_price} <br>
在没有登陆的时候显示  普通会员价,登陆之后就显示会员对应的等级和价格。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: