Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public function addcart(){
  2. if(isset($this->session->userdata)){
  3. $type = $this->session->userdata('type');
  4. $username = $this->session->userdata('username');
  5. $this->db->select('id_product ,price');
  6. $query = $this->db->get('product', array('title'=> $this->input->post('title')));
  7.  
  8. if($query->num_rows() >0){
  9. $row = $query->row();
  10. $data = array(
  11. 'id' => $row->id_product,
  12. 'qty' => $this->input->post('quantity'),
  13. 'price' => $row->price,
  14. 'name' => $this->input->post('title'),
  15. //'options' => array('Size' => 'L', 'Color' => 'Red')
  16. );
  17.  
  18. $this->cart->insert($data);
  19. }
  20. }
  21. }
  22.  
  23. public function addcart(){
  24. if(isset($this->session->userdata)){
  25. $type = $this->session->userdata('type');
  26. $username = $this->session->userdata('username');
  27. $this->db->select('id_product ,price');
  28. $query = $this->db->get('product', array('title'=> $this->input->post('title')));
  29.  
  30. $cart['product'] = $this->cart->contents(); // get previous data from cart
  31. if($query->num_rows() >0){
  32. $row = $query->row();
  33. $id = $row->id_product;
  34. $cart['product'][$id] = array(
  35. 'id' => $row->id_product,
  36. 'qty' => $this->input->post('quantity'),
  37. 'price' => $row->price,
  38. 'name' => $this->input->post('title'),
  39. //'options' => array('Size' => 'L', 'Color' => 'Red')
  40. );
  41.  
  42. $this->cart->insert($cart); //update cart
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement