[eluser]penta997[/eluser]
Hello. I'm using a cart library to get orders in my web bookstore. But when I call a addCart function on one of my book it's works, but not all the time. Please, help
There is my model function:
Code:
function get_books_by_ID($id)
{
$this->db->where('BOOK_ID', $id);
$query = $this->db->get('books');
return $query;
echo vardump($query);
}
Controller function:
Code:
function addCards()
{
$id = $this->uri->segment(3);
$query = $this->Kategorie_model->get_books_by_ID($id);
if($query->num_rows() > 0)
{
foreach($query->result() as $item)
{
$data = array(
'id' => $item->BOOK_ID,
'qty' => 1,
'price' => $item->BOOK_Price,
'name' => $item->BOOK_Title
);
$this->cart->insert($data);
}
}
}
And part of view
Code:
<tr>
<td class="color"><b>Cena: </b><?php echo $data->BOOK_Price;?>zł</td><td class="border" id="koszyk" ><?php echo anchor('ksiegarnia/addCards/'.$data->BOOK_ID.'/', 'Koszyk'); ?></td>
</tr>
<tr>
and index view, where I displaing a cart total and total_items
Code:
<tr>
<td><?php echo $this->cart->total().'zł';?></td><td><?php echo $this->cart->total_items();?></td>
</tr>