php - Codeigniter cart can't insert data -


i'm trying add data codeigniter (hmvc codeigniter) chopping cart , display it, i'm using method in main cart controller:

function add_to_cart(){     $this->load->library('cart');      // data     $userid = $this->input->post('userid');     $eventid = $this->input->post('eventid');     $tickedid = $this->input->post('tickedid');      // ticket data     $this->load->module('ticket');     $ticket_query = $this->ticket->get_where($tickedid);      //echo $this->session->all_userdata();      foreach($ticket_query->result() $ticket_data){         $ticketprice = $ticket_data->price;         $ticketcategory = $ticket_data->category;     }      //echo 'tickedid: '.$tickedid.' price: '.$ticketprice.' category: '.$ticketcategory;      // add item cart     $data_items = array(            'id'      => $tickedid,            'qty'     => 1,            'price'   => $ticketprice,            'category'    => $ticketcategory,            'options' => array()         );      $this->cart->insert($data_items);      $cart = $this->cart->contents();     echo '<pre>';     echo print_r($cart);     echo '</pre>';     } 

basically i'm getting userid, eventid , tickedid variables session, run query ticked specific id. run through results of query , $thicketprice , $ticketcategory variables it. attempt set variables in $data_items insert in cart itself. attempt echo contents of care , empty array.

the session, database , cart libraries autoloaded , sessions using database, have ci_sessions table. sessions have ecrypted key, wrong?

some attention successful cart insert:

  • 'price' > 0
  • 'name' (or similar field) better not in unicode

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -