You should create functions in a controller like insert, update, delete, and clear cart etc. eg : for insert new item in cart write below code that accepts value.
$cartItem = array(
'id' => 'MOTOG5',
'qty' => 5,
'price' => 100.99,
'name' => 'Motorola Moto G5 - 16 GB',
'options' => array(
'ram' => '3GB',
'Color' => 'Fine Gold'
)
);
And create functions in model for cart tasks like insert, update, delete, clear etc.
eg : for insert items in cart
$this->cart->insert($cartItem);
The insert() method will return the $rowid if you successfully insert a single item. so you can check that item has inserted or not and show related message to user.