我正在尝试通过在控制器中发出命令来从购物车中删除该物品。这是我的代码:
function remove($rowid) {
$data = array(
'rowid' => $rowid,
'qty' => 0
);
$this->cart->update($data);
redirect('bookings');
}
现在,当我单击链接以删除该项目时,它返回错误“404 页面未找到”。这是示例网址:
http://example.com/reservation/bookings/remove/c81e728d9d4c2f636f067f89cc14862c
“remove()”函数与我的“add()”位于同一个文件中,可以正常工作。
这是我的“add()”函数的代码:
public function add()
{
$this->load->model('Bookings_model');
$this->load->helper('url');
$this->load->library('session');
$this->load->library('cart');
$bookings = $this->Bookings_model->get($this->input->post('id'));
$data['type'] = $this->input->post('type');
$data['checkin'] = $this->input->post('checkin');
$data['checkout'] = $this->input->post('checkout');
$data['nights'] = (strtotime($data['checkout']) - strtotime($data['checkin'])) / (60 * 60 * 24);
$insert = array(
'id' => $this->input->post('id'),
'name' => $bookings->room_type,
'checkin' => $data['checkin'],
'checkout' => $data['checkout'],
'nights' => $data['nights'],
'price' => $bookings->default_price,
'qty' => 1,
'amount' => $bookings->default_price
);
$this->cart->insert($insert);
redirect('bookings');
}
我尝试了所有方法,但现在已经两天了,我仍然找不到解决方案。