Page 109 - Framework Codeigniter 2
P. 109

www.koder.web.id – Kumpulan tutorial komputer

            7.       <a href='<?php echo site_url("cart/add/$product->id") ?>'
                 >Beli</a>
            8.      </li>
            9.      <?php endforeach ?>
            10.  </ul>
            11.  <?php else : ?>
            12.      <p>Produk kosong.</p>
            13.  <?php endif ?>

            Adapun tampilan dari view diatas adalah sebagai berikut























            Ketika user mengklik link beli pada list produk maka user akan di redirect ke halaman add item ke
            shoping cart. Adapun view yang digunakan untuk melihat daftar shopping cart adalah


            1.  <h1>Shopping cart anda</h1>
            2.  <?php echo form_open('cart/update'); ?>
            3.
            4.  <table cellpadding="6" cellspacing="1" style="width:100%" border="0">
            5.
            6.  <tr>
            7.    <th>QTY</th>
           8.    <th>Item Description</th>
           9.    <th style="text-align:right">Item Price</th>
           10.   <th style="text-align:right">Sub-Total</th>
           11. </tr>
           12.
           13. <?php $i = 1; ?>
           14.
           15. <?php foreach($this->cart->contents() as $items): ?>
           16.
           17.     <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
           18.
           19.     <tr>
           20.       <td><?php echo form_input(array('name' => $i.'[qty]', 'value' =>
           21.           $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
           22.       <td>
           23.         <?php echo $items['name']; ?>
           24.
           25.         <?php if ($this->cart->has_options($items['rowid']) == TRUE):
                ?>
           26.
           27.                 <p>
            104
   104   105   106   107   108   109   110   111   112   113   114