dede posttocar.php.,plus/posttocar.php · lsok/jiushu2 - Gitee.com

/**

*

* 发送到购物车

*

* @version $Id: posttocar.php 1 15:38 2010年7月8日Z tianya $

* @package DedeCMS.Site

* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.

* @license http://help.dedecms.com/usersguide/license.html

* @link http://www.dedecms.com

*/

require_once (dirname(__FILE__) . "/../include/common.inc.php");

require_once DEDEINC.'/shopcar.class.php';

$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();

}

$cts = GetChannelTable($rs['channel']);

$rows = $dsql->GetOne("SELECT aid as id,trueprice as price,units FROM `$cts[addtable]` WHERE aid='$id'");

if(!is_array($rows))

{

ShowMsg("该商品已不存在!","-1");

exit();

}

$rows['buynum'] = $buynum;

$rows['title'] = $rs['title'];

$cart->addItem($id, $rows);

ShowMsg("已添加加到购物车,查看购物车","car.php");

exit();

}

elseif($do == 'del')

{

/*

function delItem(); del products from car

*/

if(!isset($ids))

{

ShowMsg("请选择要删除的商品!","-1");

exit;

}

if(is_array($ids))

{

foreach($ids as $id)

{

$id = intval($id);

$cart->delItem($id);

}

}

else

{

$ids = intval($ids);

$cart->delItem($ids);

}

ShowMsg("已成功删除购物车中的商品,查看购物车","car.php");

exit;

}

elseif($do == 'clear')

{

/*

function clearItem(); clear car products all!

*/

$cart->clearItem();

ShowMsg("购物车中商品已全部清空!","car.php");

exit;

}

elseif($do == 'update')

{

/*

function updateItem(); update car products number!

*/

if(isset($ids) && is_array($ids))

{

foreach($ids as $id){

$id = intval($id);

$rs = $dsql->GetOne("SELECT id,channel,title FROM #@__archives WHERE id='$id'");

if(!is_array($rs)) continue;

$cts = GetChannelTable($rs['channel']);

$rows = $dsql->GetOne("SELECT aid as id,trueprice as price,units FROM `$cts[addtable]` WHERE aid='$id'");

if(!is_array($rows)) continue;

$rows['buynum'] = intval(${'buynum'.$id});

if($rows['buynum'] < 1)

{

//如果设单位数量小于1个时更新,则移出购物车

$cart->delItem($id);

continue;

}

$rows['title'] = $rs['title'];

$cart->addItem($id, $rows);

}

}

ShowMsg("购物车中商品已全部更新!","car.php");

exit;

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值