function modifycart() { $shopid = intval(IReq::get('shopid')); $goods_id = intval(IReq::get('goods_id')); $targetnum = intval(IReq::get('num')); if ($shopid < 0) { $this->message('店铺获取失败'); } if ($goods_id < 0) { $this->message('获取商品失败'); } if ($targetnum < 1) { $this->message('请执行删除该商品操作'); } $Cart = new smCart(); $plate = intval(IReq::get('plate')); if (!empty($plate)) { $Cart->cartName = 'platesmcart'; } $carinfo = $Cart->getMyCart(); if (!isset($carinfo['list'][$shopid]['data'][$goods_id]['count'])) { $this->message('此商品未添加到购物车'); } $js = $targetnum - $carinfo['list'][$shopid]['data'][$goods_id]['count']; $num = $js; $checkinfo = $Cart->add($goods_id, $num, $shopid); if ($checkinfo == false) { $this->message($Cart->getError()); } $this->success('操作成功'); }
function downcart() { $shopid = intval(IReq::get('shopid')); $goods_id = intval(IReq::get('goods_id')); $num = intval(IReq::get('num')); if ($shopid < 0) { $this->message('店铺获取失败'); } if ($goods_id < 0) { $this->message('获取商品失败'); } if ($num < 1) { $this->message('商品数量失败'); } $Cart = new smCart(); $plate = intval(IReq::get('plate')); if (!empty($plate)) { $Cart->cartName = 'platesmcart'; } $carinfo = $Cart->getMyCart(); if (!isset($carinfo['list'][$shopid]['data'][$goods_id]['count'])) { $this->message('此商品未添加到购物车'); } if ($carinfo['list'][$shopid]['data'][$goods_id]['count'] == $num) { $checkinfo = $Cart->del($goods_id, $shopid); $this->success('操作成功'); } else { $num = $num * -1; $checkinfo = $Cart->add($goods_id, $num, $shopid); } if ($checkinfo == false) { $this->message($Cart->getError()); } $this->success('操作成功'); }