Friday, 15 July 2011

codeigniter - store session cart to database -



codeigniter - store session cart to database -

sorry asking old questions, , know i've read before inquire here, it's can utilize database adding more cart without limitation. seek utilize ci_sessions table store session still no luck, can adding 6 items maximum.

please help me, looking illustration 2 days , result nothing

edited view

<table id="box-table-a" summary="employee pay sheet"> <thead> <tr> <th scope="col">description</th> <th scope="col">price</th> <th class="centered" scope="col">options</th> </tr> </thead> <tbody> <?php foreach ($foto_produk->result() $key => $value) {?> <tr> <td><?php echo $value->description;?></td> <td><?php echo $value->price;?></td> <td class="centered"><input type="checkbox" name="produk_foto[]" value="<?php echo $value->id;?>" /></td> </tr> <?php }?> </tbody> </table>

here's controller code

if($this->input->post('produk_foto')){ $id_foto = $this->input->post('produk_foto'); foreach ($id_foto $key => $value) { $this->db->where('id', $value); $query = $this->db->get('foto_product'); if($query->num_rows() > 0){ foreach($query->result() $ids => $rows){ echo $rows->id.'<br />'; $data_produk = array( 'user_data'=> array( 'id' => $rows->id, 'price' => $rows->price, 'name' => $rows->description, 'qty' => $rows->aantal ) ); $this->cart->insert($data_produk); } } } }

and view code

<?php if(!$this->cart->contents()):?> <div class="alert-box warning">the regular products empty.</div> <div class="clearfix"></div> <?php else:?> <hr> <h4>regular products</h4> <div class="order_detail" id="display"> <table> <thead> <tr> <th>description</th> <th>quantity</th> <th>price per item(s)</th> <th>total</th> <th>remove</th> </tr> </thead> <tbody> <?php foreach($this->cart->contents() $rows):?> <tr> <td style="font-weight:bold;"><?php echo $rows['name'];?></td> <td> <?php echo form_open(current_url());?> <input type="text" size="3" name="quantity" value="<?php echo $rows['qty'];?>" /> <input type="hidden" size="3" name="rowid" value="<?php echo $rows['rowid'];?>" /> <input type="submit" name="update" value="update" /> <?php echo form_close();?> </td> <td><?php echo $rows['price'];?></td> <td><?php echo $this->cart->format_number($rows['subtotal']);?></td> <td><a href="<?php echo base_url('index.php/en/payment/delete_item_product/'.$rows['rowid'].'');?>">delete</a></td> </tr> <?php endforeach;?> </tbody> <tfoot> <tr> <td colspan="3">total products</td> <td colspan="3">&euro; <?php echo $this->cart->format_number($this->cart->total());?></td> </tr> <tr> <td colspan="3">total shipping</td> <td colspan="3"></td> </tr> <tr> <td colspan="3"></td> <td colspan="3" style="padding:0;text-align:center;"> <p>total :</p> <span class="tot">&euro; <?php echo $this->cart->format_number($this->cart->total());?></span> </td> </tr> </tfoot> </table> </div> <?php endif;?>

with code want insert using checkbox array, , have more 6 checkbox

thank in advance

ok it's solved self..

i don't know in name of product there special characters..

and shame of me..

but give thanks anyway

codeigniter session shopping-cart

No comments:

Post a Comment