php - Code Igniter - carts library random works -


i’m using cart library orders in web bookstore. when call addcart function on 1 of book it’s works, not time. please, help

there model function:

function get_books_by_id($id) {     $this->db->where('book_id', $id);      $query =  $this->db->get('books');     return $query;     echo vardump($query); }  

controller:

function addcards($id=1) {     $query = $this->kategorie_model->get_books_by_id($id);     if($query->num_rows() > 0)     {         $item = $query->row();          $data = array(             'id'      => $item->book_id,             'qty'     => 1,             'price'   => $item->book_price,             'name'    => $item->book_title         );         $this->cart->insert($data);     } } 

view:

<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> 

update:

vardump nothing necessary. want use var_dump. problem related adding items session carts library. have bookstore, , when call addcarts function, items added carts, , cart function total() , total_items displaying it, when call function, nothing happened. items not add carts. don't why thing have place. why carts library works randomly?

i ran issue , seems in codeigniter cart library insert function checks product(s) id , name against regex allow alpha-numeric, dashes, underscores , periods

adjust regex may come up:

$this->cart->product_id_rules = '.a-z0-9_';

$this->cart->product_name_rules = '.\:-_ a-z0-9';

in case randomly add thing carts too. if turn on logging , check you'll able see name or id may contain invalid chars


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -