2013-11-15 3 views
0

그래서이 CI 코드를 가지고 있는데, 어떤 이유로이 정보가 장바구니에 추가되지 않지만 정보면 $ data가 제대로 인쇄됩니다. 아무도 모르게 무슨 일이 일어 났습니까? 그것은 잘 작동하는 데 사용하고, 나는 잠시 동안이 함수를 건드리지 않았습니다. 매개 변수가 설정되어 있는지 확인하기 위해 if 문이 있습니다.CodeIgniter가 카트에 항목을 추가하지 않았습니다.

<?php 
/* test data 
$this->input->post('product_id') = 1 
$this->input->post('name')  = 'ballons' 
$this->input->post('qty')  = 10 
$price       = 9.99 
$this->input->post('img')  = 'http://example.com/product_img.jpg' 
$this->input->post('special_instructions') = 'long string explenation' 
$this->input->post('options') = array('color' => 'red') 
*/ 
// set cart's info 
$data = array(
'id'  => $this->input->post('product_id'), 
'name'  => $this->input->post('name'), 
'qty'  => $this->input->post('qty'), 
'price'  => $price, 
'img'  => $this->input->post('img') 
); 

// check if special instructions are set 
if($this->input->post('special_instructions')) 
    $data['special_instructions'] = $this->input->post('special_instructions'); 

// check if options are available 
if($this->input->post('options')) 
    $data['options'] = array('type' => $this->input->post('options')); 


// add data to cart 
$this->cart->insert($data); 

die(print_r($data).$this->cart->contents()); 
?> 
+0

붙여 넣기 할 수있는 장바구니 개체의 삽입 기능이 있습니까? – skrilled

+0

오류가 있습니까? 우리에게 cart-> insert –

+0

오류나 아무것도 표시하지 말고 데이터가 추가되지 않습니다. 카트가 작동하는지, 데이터가 수동으로 추가되는 다른 기능이 있다는 것을 알지만 작동하는이 1 개는 자동으로 작동하지만 그렇지 않습니다. (나는 미쳐 갈 것입니다.) < – syntrax

답변

0

내 생각에 쿠키에 할당 된 4K를 초과하고 있습니다. 장바구니에 저장하는 데 필요한 많은 정보입니다. 장바구니 세션에서 일부 필드를 제거하고 필요할 때 데이터베이스에서 검색하는 것이 좋습니다.

+0

정보 제거를 시도했습니다. 요구 사항 만 남겨두면 항목을 추가하지 않지만 다른 기능은 작동합니다. << – syntrax

관련 문제