Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 1.05 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Error Adding to cart in Codeigniter shopping cart class
  2. class Cart extends CI_Controller {
  3.  
  4.     public function __construct() {
  5.         parent::__construct();
  6.     $this->load->model('cart_model', 'cart_model', TRUE);
  7.     $this->load->library('cart');
  8.     }
  9.  
  10.     public function index() {
  11.     echo $this->cart->total_items();
  12.     }
  13.  
  14.     public function add(){
  15.        $data = array(
  16.                'id'      => 'ssksdu_123ABC',
  17.                'qty'     => 3,
  18.                'price'   => 39.95,
  19.                'name'    => 'T-Shirt',
  20.                'options' => array('Size' => 'L', 'Color' => 'Red')
  21.        );
  22.     $add = $this->cart->insert($data);  
  23.     if($add){
  24.         redirect('cart');
  25.     }
  26.     }
  27. }
  28.        
  29. $config['sess_cookie_name'] = 'ci_session';
  30. $config['sess_expiration']  = 0;
  31. $config['sess_expire_on_close'] = FALSE;
  32. $config['sess_encrypt_cookie']  = TRUE;
  33. $config['sess_use_database']    = TRUE;
  34. $config['sess_table_name']  = 'ci_sessions';
  35. $config['sess_match_ip']    = FALSE;
  36. $config['sess_match_useragent'] = TRUE;
  37. $config['sess_time_to_update']  = 300;