一次一个人让我给他用dedecms做程序,然后商品的地方需要不同的会员不同的价格,必须登录才能购买,然后找了一下流程文件,自己改了一下 1.首先我们后台商品添加几个字段价格的 我添加是 trueprice 优惠价格 hprice 会员价格 gprcie 高级会员价格 2.然后修改/plus/posttocar.php这个文件的源代码(修改几个地方,给大家讲一下很简单)
require_once (dirname(__FILE__) . "/../include/common.inc.php"); require_once DEDEINC.'/shopcar.class.php'; //购物车的类 require_once DEDEINC.'/memberlogin.class.php'; //会员登录的类 $cfg_ml = new MemberLogin(); //实例化类 if(empty($cfg_ml->M_ID)){ //如果没有登录自动跳转到登录页面 ShowMsg("您没有登录!", "/member/login.php", false, 5000); exit; }else{ $cart = new MemberShops(); $do = isset($do) ? trim($do) : 'add'; if($do == 'add') { /* function addItem(); add a product to car */ $buynum = isset($buynum) && is_numeric($buynum) ? $buynum : 1; $id =empty($id)? "" : intval($id); $buynum = ($buynum < 1) ? 1 : $buynum; $rs = $dsql->GetOne("SELECT id,channel,title FROM #@__archives WHERE id='$id'"); if(!is_array($rs)) { ShowMsg("该商品已不存在!","-1"); exit(); } //我们通过userid在会员里边找 rank这个字段 就是等级字段 $userid = $cfg_ml->M_ID; $result=$dsql->Getone("select rank from #@__member where mid='$userid'"); $dengji=$result[rank]; $cts = GetChannelTable($rs['channel']); //这里根据等级值 判断输出哪个价格 这样就结束了 switch ($dengji) { case 10: $rows = $dsql->GetOne("SELECT aid as id,trueprice as price,units FROM `$cts[addtable]` WHERE aid='$id'"); break; case 20: $rows = $dsql->GetOne("SELECT aid as id,hprice as price,units FROM `$cts[addtable]` WHERE aid='$id'"); break; case 50: $rows = $dsql->GetOne("SELECT aid as id,gprice as price,units FROM `$cts[addtable]` WHERE aid='$id'"); break; default: echo "您不是会员"; break; } if(!is_array($rows)) { ShowMsg("该商品已不存在!","-1"); exit(); } $rows['buynum'] = $buynum; $rows['title'] = $rs['title']; $cart->addItem($id, $rows); ShowMsg("已添加加到购物车,<a href='car.php'>查看购物车</a>","car.php"); exit(); }欢迎转载 转载请注明来自微度网络http://yun.widuu.com
发表评论 取消回复