在做购物车页面时,我只能将一个产品添加到购物车类,antor产品没有进入该类。我的控制器,型号 控制器类 公共功能购买($ id){
$product = $this->mproduct->find($id);
$res['result'] = $product;
$data = array(
'id' => $product->pro_id,
'qty' => '1',
'price' => $product->pro_price,
'name' => $product->pro_title,
);
$array = (array) $data;
$this->cart->insert($array);
$this->load->view('cart',$res);
}
public function delete($row_id){
$this->cart->update(array('rowid' => $row_id,'qty' => 0));
$this->load->view('cart');
}
public function update(){
$i=1;
foreach ($this->cart->contents() as $items) {
$this->cart->update(array('rowid' =>$items['rowid'],'qty' => $_POST['qty'.$i]));
$i++;
}
$this->load->view('cart');
}
模特
public function find($id)
{
$this->db->where('pro_id',$id);
return $this->db->get('products')->row();
}