Page 110 - Framework Codeigniter 2
P. 110
www.koder.web.id – Kumpulan tutorial komputer
28. <?php foreach ($this->cart->product_options($items['rowid']) as
29. $option_name => $option_value): ?>
30.
31. <strong><?php echo $option_name; ?>:</strong>
32. <?php echo $option_value; ?><br />
33.
34. <?php endforeach; ?>
35. </p>
36.
37. <?php endif; ?>
38.
39. </td>
40. <td style="text-align:right">
41. <?php echo $this->cart->format_number($items['price']); ?></td>
42. <td style="text-align:right">$
43. <?php echo $this->cart->format_number($items['subtotal']); ?></td>
44. </tr>
45.
46. <?php $i++; ?>
47.
48. <?php endforeach; ?>
49.
50. <tr>
51. <td colspan="2"> </td>
52. <td class="right"><strong>Total</strong></td>
53. <td class="right">$
54. <?php echo $this->cart->format_number($this->cart->total());
?></td>
55. </tr>
56.
57. </table>
58.
59. <p><?php echo form_submit('', 'Update your Cart'); ?></p>
60.
61. <a href="<?php echo site_url('produk') ?>">Kembali</a>
Perhatikan baris 15, fungsi $this->cart->contents() digunakan untuk mendapatkan seluruh data
cart yang telah disimpan di session. Semua item tadi akan kita simpan juga dalam sebuah inputan
yang bersifat hidden sehingga memudahkan kita dalam proses update cart. Selain itu library cart
juga sudah dilengkapi dengan fungsi untuk menampilkan jumlah belanja yang telah dilakukan
dengan fungsi $this->cart->total();
105