[eluser]Ali Fattahi[/eluser]
hi everybody
i have a problem in shopping cart library in code igniter
i added a product to shopping cart and i got product information with $this->input->post
and all of thing is ok
but when i wanna redirect a user to their shopping cart without any posted information and saw empty shopping cart
i other word when i posted information to this function the shopping cart haven't any problem but when i typing the cart url in browser i see the basket is empty but i sent a product to shopping cart before :-(
i addition in this cart i have only one product , see in foreach ()
can you please help me about this problem
here is my code :
Code:
function simplepaypost()
{
$acc_code = $this->db->escape_str($this->input->post('acc_number'));
$desc = $this->db->escape_str($this->input->post('desc'));
$amount = (float) $this->db->escape_str($this->input->post('amount'));
$owner = $this->db->select('name,family')->from('users')->where('acc_code',$acc_code)->get()->result();
if ($this->input->post('acc_number') && $this->input->post('desc') && $amount > 100 )
{
$item = array(
'id' => $acc_code,
'qty' => 1,
'price' => $amount,
'name' => $desc
);
$test = 1;
$this->cart->insert($item);
}
$prod = array();
foreach( $this->cart->contents() as $items )
{
$prod['desc']= $items['name'];
$prod['id']= $items['id'];
$prod['price']= $items['price'];
}
$owner = $this->db->select('name,family')->from('users')->where('acc_code',$prod['id'])->get()->result();
$data['entry'].='
<table class="tbl" border="0" width="98%">
<tr>
<th><span lang="fa">Reciever</span></th>
<th style="width: 200px; height: 25px"><span lang="fa">Descriotion</span></th>
<th style="width: 130px; height: 25px"><span lang="fa">Amount</span></th>
</tr>
<tr>
<td>'.$owner[0]->name.' '.$owner[0]->family.'</td>
<td>'.$prod['desc'].'</td>
<td>'.$prod['price'].'</td>
</tr>
</table>';
$this->load->view('main_index',$data);
}