Welcome Guest, Not a member yet? Register   Sign In
problem show data from cart....
#1

[eluser]newbee[/eluser]
hi guys, i have some trouble to make view from cart->content. I surely there must be wrong with my code but i can't found it,..

controller
Code:
class Transaksi extends Controller
    {
        function Transaksi()
        {
            parent::Controller();
            $this->load->model('Produk_model','',TRUE);
        }
        var $title='member';
        function index()
        {
            if($this->session->userdata('user')=='member')
            {
                $this->main();
            }else
            {
                redirect('login');
            }
        }
        
        function main()
        {
            if($this->Produk_model->check_id()==TRUE)
            {
                $this->session->set_flashdata('message','Satu produk telah masuk ke dalam daftar belanja.');
                redirect('produk');
            }else{  
                $this->session->set_flashdata('message','Data tidak masuk.');
                redirect('produk');
            }      
        }
        
        function isi_cart()
        {
            $data['title']=$this->title;
            $data['h2_title']='Member > isi cart';
            $data['main_view']='transaksi/cart';
            
            $tmpl=array('table_open'=>'<table border="0",cellpading="0",cellspacing="0">','row_alt_start'=>'<tr class="zebra">','row_alt_end'=>'</tr>');
            $isi=$this->cart->contents();
            if(!empty($isi))
            {
                $this->table->set_template($tmpl);                
                $this->table->set_empty("&nbsp;");
                $this->table->set_heading('Nama','Seri','Jumlah','Harga','Actions');
                $i=0;
                foreach($this->cart->contents() as $t)
                {
                    ++$i;
                    $id[$i]=$t['rowid'];
                    $this->table->add_row($t['nama'],$t['seri'],$t['jumlah'],$t['harga'],anchor('transaksi/ubah/'.$row['rowid'],'ubah jumlah',array('class'=>'update')).''.anchor('transaksi/hapus/'.$row['rowid'],'hapus',array('class'=>'delete','onclick'=>"return confirm('Anda yakin akan menghapus data ini?')")));
                }
                $data['table']=$this->table->generate();
            }else
            {
                $data['message']='Tidak ada satu pun data produk.';
            }
            $this->load->view('template',$data);
        }
        
    }

model
Code:
class Produk_model extends model
    {
        function Produk_model()
        {
            parent::Model();
        }
        
        var $table='produk';

                function check_id()
        {
            $id=$this->input->post('id_produk');
            $jumlah=$this->input->post('jumlah');
            $this->db->where('id_produk',$id);
            $query=$this->db->get($this->table,1);
            if($query->num_rows() > 0)
            {
                foreach ($query->result() as $row)  
                {  
                    $data = array(  
                    'id_produk'=>$id,  
                    'jumlah'=>$jumlah,  
                    'harga'=>$row->harga,  
                    'nama'=>$row->nama,
                    'berat'=>$row->berat
                    );  
                    $this->cart->insert($data);
                }
                return TRUE;
            }else
            {
                return FALSE;
            }
        }

view (show cart content)
Code:
&lt;?php
    echo ! empty ($h2_title) ? '<h2>'.$h2_title.'</h2>':'';
    
    echo ! empty ($message) ? '<p class="message">'.$message.'</p>':'';
    
    $flashmessage=$this->session->flashdata('message');
    
    echo ! empty ($flashmessage) ? '<p class="message">'.$flashmessage.'</p>':'';
    
?&gt;
    <div id="cart_list">
        <div id="cart_content">
            &lt;?php echo ! empty ($table) ? $table :'';?&gt;
        </div>
    </div>
    
&lt;?php    
    echo ! empty ($pagination) ? '<div class="pagination">'.$pagination.'</div>' : '';
?&gt;

Thank You...
#2

[eluser]newbee[/eluser]
i'm sorry already solved,..




Theme © iAndrew 2016 - Forum software by © MyBB