codeigniter.com cart
Using CodeIgniter Cart Library to Manage Shopping Cart
Load Cart Library
php $this->load->library('cart');
Insert Item to Cart ```php $data = array( 'id' => 'sku_123', 'qty' => 1, 'price' => 39.95, 'name' => 'T-shirt', 'options' => array('Size' => 'L', 'Color' => 'Red') );
$this->cart->insert($data); ```
Display Cart Content
php foreach ($this->cart->contents() as $item) { echo $item['id']; echo $item['qty']; echo $item['price']; echo $item['name']; }
Update Cart ```php $data = array( 'rowid' => 'b6b8d3a29a7b33c5da1237da9b3b4be9', 'qty' => 3 );
$this->cart->update($data); ```
Remove Item from Cart
php $rowid = 'b6b8d3a29a7b33c5da1237da9b3b4be9'; $this->cart->remove($rowid);
Destroy Cart
php $this->cart->destroy();