CodeIgniter Forums
how to insert data from shopping cart into db ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to insert data from shopping cart into db ? (/showthread.php?tid=40027)



how to insert data from shopping cart into db ? - El Forum - 03-28-2011

[eluser]Keloo[/eluser]
Hi,
I'm working on an online store with codeigniter.
The problem is that I've added the data into the cart using the cart lib provided by CI, but I really don't know how to process that data, how to insert it into the db.
I would really appreciate your help, on this one.


how to insert data from shopping cart into db ? - El Forum - 03-28-2011

[eluser]ELRafael[/eluser]
Code:
foreach ( $this->cart->contents() as $cart )
{
  $insert['name'] = $cart['name'];
  $insert['qty'] = $cart['qty'];
  $insert['price'] = $cart['price'];
  $this->db->insert('table', $insert);
}

$this->cart->contents() will be your friend for that task