I have a product page and when the user clicks the "add to cart" button the function below is triggered and the desk_id and price is parsed into the function. The variables are then referenced to the carts data array which is inserted into the cart.
My problem is that nothing gets added to the cart with these variables in the $data array but it works fine when I just add strings. I have tested to make sure the database returns the product title correctly and have tried converting these variables to strings but it makes no difference.
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');
}
}
}