我有一個產品頁面,當用戶點擊「加入購物車」按鈕下方的功能被觸發,desk_id和價格被解析到函數變量添加。然後將變量引用到插入到購物車中的購物車數據數組中。無法將數據到車有數據陣列(僅字符串)
我的問題是,沒有被添加到與$ data數組這些變量的車,但它工作正常,當我只需要添加字符串。我已經過測試,以確保數據庫正確地返回產品標題,並嘗試將這些變量轉換爲字符串,但它沒有區別。
function request_desk_booking($desk_id, $price){
$this->load->model('search_model');
//Query database to get desk title because parsing strings through the url does not work
if($query = $this->search_model->desk_details_cart($desk_id)){
//convert title to string
$title = $query['company'].', '.$query['Town'];
$name = (string) $title;
//check to make sure values are not null
if($desk_id !== null && $price !== null){
$this->load->library('cart');
$data = array(
'id' => $desk_id,
'qty' => 1,
'price' => $price,
'name' => $name
);
//insert data into cart
$this->cart->insert($data);
$this->load->view('request_booking', $data);
}else{
$this->load->view('request_booking');
}
}
}