displaying the cart codeigniter

Solutions on MaxInterview for displaying the cart codeigniter by the best coders in the world

showing results for - "displaying the cart codeigniter"
Alexia
06 Mar 2019
1$data = array(
2        'id'      => 'sku_123ABC',
3        'qty'     => 1,
4        'price'   => 39.95,
5        'name'    => 'T-Shirt',
6        'options' => array('Size' => 'L', 'Color' => 'Red')
7);
8
9$this->cart->insert($data);
10
Dario
14 Jun 2017
1<?php echo form_open('path/to/controller/update/method'); ?>
2
3<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
4
5<tr>
6        <th>QTY</th>
7        <th>Item Description</th>
8        <th style="text-align:right">Item Price</th>
9        <th style="text-align:right">Sub-Total</th>
10</tr>
11
12<?php $i = 1; ?>
13
14<?php foreach ($this->cart->contents() as $items): ?>
15
16        <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
17
18        <tr>
19                <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
20                <td>
21                        <?php echo $items['name']; ?>
22
23                        <?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
24
25                                <p>
26                                        <?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
27
28                                                <strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />
29
30                                        <?php endforeach; ?>
31                                </p>
32
33                        <?php endif; ?>
34
35                </td>
36                <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
37                <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
38        </tr>
39
40<?php $i++; ?>
41
42<?php endforeach; ?>
43
44<tr>
45        <td colspan="2"> </td>
46        <td class="right"><strong>Total</strong></td>
47        <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
48</tr>
49
50</table>
51
52<p><?php echo form_submit('', 'Update your Cart'); ?></p>
53