Welcome Guest, Not a member yet? Register   Sign In
shopping cart- adding problem
#1

[eluser]elombashy[/eluser]
hii

for some reason, some of the products that I add by the next code, arn't added correctly.
when there are about 8-9 products, the cart start removing previews product and insert new one instead
can anyone help me solving this annoying problem?

Code:
function add_to_cart($id) {
        $product = $this->cart_m->get($id);
        $products=$this->cart->contents();
        $ids=array();
        
        foreach ($products AS $k=>$v){            
            $ids[$v['id']]=$k;
        }

        if(isset($ids[$id])){
            $rowid = $ids[$id];
            $update_data=array(
                    'rowid'=> $rowid,
                    'qty'  => $v['qty']+1
                );
                $this->cart->update($update_data);
        }
        
        else{
            $data = array(
                'id' => $id,
                'name' => $product[0]['name'],
                'qty' => 1,
                'price' => $product[0]['price'],
                'image'   => $product[0]['image']            
            );
            $this->cart->insert($data);
            
        }

the Model (Cart_m):

Code:
function get($id) {
        $data=array();
        $this->db->select('name, price, image')->from('product')
        ->join('product_description','product.product_id=product_description.product_id')
        ->where('product.product_id',$id)->where('language_id',2);
        $results = $this->db->get();
        if($results->num_rows()==1){
            foreach($results->result_array() AS $result){
              $data[]=$result;
            }
        
        }
        return $data;
    }
#2

[eluser]elombashy[/eluser]
I found the problem..
that's because the session doesn't hold than 40k and to fix this, you have to change the config file:

$config['sess_use_database'] = TRUE;

and add a table into the sql database:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

what really annoying, is that this valuable information is not written in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB