Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function addcart(){
- if(isset($this->session->userdata)){
- $type = $this->session->userdata('type');
- $username = $this->session->userdata('username');
- $this->db->select('id_product ,price');
- $query = $this->db->get('product', array('title'=> $this->input->post('title')));
- if($query->num_rows() >0){
- $row = $query->row();
- $data = array(
- 'id' => $row->id_product,
- 'qty' => $this->input->post('quantity'),
- 'price' => $row->price,
- 'name' => $this->input->post('title'),
- //'options' => array('Size' => 'L', 'Color' => 'Red')
- );
- $this->cart->insert($data);
- }
- }
- }
- public function addcart(){
- if(isset($this->session->userdata)){
- $type = $this->session->userdata('type');
- $username = $this->session->userdata('username');
- $this->db->select('id_product ,price');
- $query = $this->db->get('product', array('title'=> $this->input->post('title')));
- $cart['product'] = $this->cart->contents(); // get previous data from cart
- if($query->num_rows() >0){
- $row = $query->row();
- $id = $row->id_product;
- $cart['product'][$id] = array(
- 'id' => $row->id_product,
- 'qty' => $this->input->post('quantity'),
- 'price' => $row->price,
- 'name' => $this->input->post('title'),
- //'options' => array('Size' => 'L', 'Color' => 'Red')
- );
- $this->cart->insert($cart); //update cart
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement