codeigniter CodeIgniter Shopping Cart Adding Items In Cart

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any codeigniter Question?