Tutorial by Examples

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',...
$data = array( array( 'id' => 'sku_123ABC', 'qty' => 1, 'price' => 39.95, 'name' => 'T-Shirt', 'options' => array('Size' => 'L', 'Color' => 'Red') ), array( 'id' =>...
As we can add multiple elements in Cart array and then add it to cart session, but there are 4 basic elements which Cart class requires to add data successfully in cart session. id (string) qty (number) price (number, decimal) name (String) And if you want to add more options regardin...
You can show cart items by loop through cart or you can display single item from cart. $cartContents = $this->cart->contents(); This will return an array of cart items so you can loop through this array using foreach loop. foreach ($cartContents as $items){ echo "ID : ". ...
Rowid : The row ID is a unique identifier that is generated by the cart code when an item is added to the cart. The reason a unique ID is created is so that identical products with different options can be managed by the cart. Every item in cart has a rowid element and by rowid you can update cart ...
By using rowid element you can delete an item from cart. you just have to set item's qty to 0 $deleteItem = array( 'rowid' => 'b99ccdf16028f015540f341130b6d8ec', 'qty' => 0 ); $this->cart->update($data); this will delete item with this rowid.

Page 1 of 1