Welcome Guest, Not a member yet? Register   Sign In
[ASK] limit item cart
#1

[eluser]jshot[/eluser]
i have problem with CI cart class, the inserted item with cart limited on my web,

i am confused, anyone can help me,

my DB :

Code:
CREATE TABLE IF NOT EXISTS `part_mobil` (
  `no` int(10) NOT NULL auto_increment,
  `kode_part` varchar(50) NOT NULL,
  `merk_mobil` varchar(50) NOT NULL,
  `kode_mobil` varchar(50) NOT NULL,
  `kategori` varchar(50) NOT NULL,
  `gambar` varchar(50) NOT NULL,
  `nama` varchar(50) NOT NULL,
  `keterangan` varchar(1000) NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `type` varchar(50) NOT NULL,
  `stok` int(10) NOT NULL,
  `harga` bigint(50) NOT NULL,
  `tgl_input` varchar(30) NOT NULL,
  PRIMARY KEY  (`no`),
  UNIQUE KEY `kode_part` (`kode_part`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=61 ;

harga = price
kode part = product id
nama = name
keterangan = short description

my controller standard with CI cart

Code:
function index()
        {
                // show a couple products
                
                $products = $this->db->get('part_mobil');
                foreach ($products->result() as $product)
                {
                        echo '<h3>' . anchor('shop/detail/' . $product->kode_part, $product->nama) . '</h3>';
                        echo '<p><b>' . $product->harga. '</b></p>';
                        echo '<p>' . $product->keterangan . '</p>';
                        echo '<hr>';
                }
        }

function detail()
        {
                // show the product and an "add to cart" link
                $product_id = $this->uri->segment(3);
                $product = $this->db->where('kode_part', $product_id)->get('part_mobil')->row();
                
                echo '<h1>' . $product->nama . '</h1>';
                echo '<p>' . $product->keterangan . '</p>';
                echo '<p><b>' . $product->harga . '</b></p>';
                echo form_open('shop/add_to_cart');
                echo form_hidden('product_id',$product->kode_part);
                echo form_hidden('product_name', $product->nama);
                echo form_hidden('product_price', $product->harga);
                echo form_input('qty', '1');
                echo form_submit('', 'Add to Cart');
                echo form_close();
        }

function add_to_cart()        
        {
                // add the selected product to the cart
                $data = array(
                        'id' => $this->input->post('product_id'),
                        'qty' => $this->input->post('qty'),
                        'price' => $this->input->post('product_price'),
                        'name' => $this->input->post('product_name'),
                        'options' => array()
                );
                
                $this->cart->insert($data);                
                redirect('shop/show_cart');
        }

function update_cart()
        {
                $total = $this->cart->total_items();
                for ($i = 1; $i <= $total; $i++)
                {
                        $item = $this->input->post($i);
                        $data = array(
                                'rowid' => $item['rowid'],
                                'qty' => $item['qty']
                        );
                        $this->cart->update($data);
                }
                redirect('shop/show_cart');
        }
//continue


Messages In This Thread
[ASK] limit item cart - by El Forum - 12-02-2009, 10:44 AM
[ASK] limit item cart - by El Forum - 12-02-2009, 10:46 AM
[ASK] limit item cart - by El Forum - 01-12-2010, 02:57 PM
[ASK] limit item cart - by El Forum - 01-12-2010, 04:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB