public function addCart() { $goods_id = I('post.goods_id'); $goods_num = I('post.goods_num'); $cart = new \Model\CartModel(); $a = $cart->addCart($goods_id, $goods_num); if ($a) { $this->redirect('cartlist'); } }
public function addCart() { //接收提交的数据 $goods_id = I('post.goods_id'); $attr = I('post.attr'); //返回一个一维数组 if ($attr) { //拼接goods_attr_id字符串 $goods_attr_id = implode(',', $attr); } $goods_count = I('post.goods_count'); $cart_model = new \Model\CartModel(); $cart_model->addCart($goods_id, $goods_attr_id, $goods_count); $this->success('添加购物车成功', U('cartlist'), 1); }