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
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
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
1$data = array(
2 'id' => 'sku_123ABC',
3 'qty' => 1,
4 'price' => 39.95,
5 'name' => 'T-Shirt',
6 'coupon' => 'XMAS-50OFF'
7);
8
9$this->cart->insert($data);
10
1$data = array(
2 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
3 'qty' => 3
4);
5
6$this->cart->update($data);
7
8// Or a multi-dimensional array
9
10$data = array(
11 array(
12 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
13 'qty' => 3
14 ),
15 array(
16 'rowid' => 'xw82g9q3r495893iajdh473990rikw23',
17 'qty' => 4
18 ),
19 array(
20 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
21 'qty' => 2
22 )
23);
24
25$this->cart->update($data);
26
1$data = array(
2 array(
3 'id' => 'sku_123ABC',
4 'qty' => 1,
5 'price' => 39.95,
6 'name' => 'T-Shirt',
7 'options' => array('Size' => 'L', 'Color' => 'Red')
8 ),
9 array(
10 'id' => 'sku_567ZYX',
11 'qty' => 1,
12 'price' => 9.95,
13 'name' => 'Coffee Mug'
14 ),
15 array(
16 'id' => 'sku_965QRS',
17 'qty' => 1,
18 'price' => 29.95,
19 'name' => 'Shot Glass'
20 )
21);
22
23$this->cart->insert($data);
24
1$data = array(
2 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
3 'qty' => 1,
4 'price' => 49.95,
5 'coupon' => NULL
6);
7
8$this->cart->update($data);
9