codeigniter.com cart

Using CodeIgniter Cart Library to Manage Shopping Cart

  1. Load Cart Libraryphp $this->load->library('cart');

  2. 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); ```

  1. Display Cart Contentphp foreach ($this->cart->contents() as $item) { echo $item['id']; echo $item['qty']; echo $item['price']; echo $item['name']; }

  2. Update Cart ```php $data = array( 'rowid' => 'b6b8d3a29a7b33c5da1237da9b3b4be9', 'qty' => 3 );

$this->cart->update($data); ```

  1. Remove Item from Cartphp $rowid = 'b6b8d3a29a7b33c5da1237da9b3b4be9'; $this->cart->remove($rowid);

  2. Destroy Cartphp $this->cart->destroy();