[eluser]suku[/eluser]
hi iam having problem in updating the cart.
there is no passage of parameters as i have to pass two parameters rowid and qty,here is code
view file
Code:
<?php foreach ($this->cart->contents() as $items): ?>
<?php echo form_open('cart/update/'.$items['rowid']); ?>// i need to pass qty as well how to pass????
<?php endforeach;?>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<th>Delete_Items</th>
<th>QTY</th>
<th>Item Description</th>
<th>Item Price</th>
<th>Sub-Total</th>
</tr>
<?php $i = 1; ?>
<?php foreach ($this->cart->contents() as $items): ?>
<?php echo form_hidden( 'hdrow' . $i, $items['rowid']); ?>
<tr>
<td><a href="<?php echo base_url().'cart/delete/'. $items['rowid'] ;?>">Delete</a></td>
<td><?php echo form_input(array('name' => 'row'. $i, 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5','class' => 'num_only')); ?></td>
<td>
<?php echo $items['name']; ?>
<?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
<p>
<?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
<strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />
<?php endforeach; ?>
</p>
<?php endif; ?>
</td>
<td><?php echo $this->cart->format_number($items['price']); ?></td>
<td>$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<tr>
<td colspan="2"> </td>
<td class="right"><strong>Total</strong></td>
<td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>
</table>
<p><?php echo form_submit('', 'Destroy your Cart'); ?></p>
<p><?php echo form_submit('', 'Update your Cart'); ?></p>
controller //only update function
Code:
function update($rowid,$qty)
{
$data = array(
'rowid' => $rowid,
'qty' => $qty
);
print_r($data);
exit;
$this->cart->update($data);
//redirect('cart/view');
}