The cart in CI3

New at the cart and struggling a little.

I am trying to send multiple updates through a multidimensional array from the view to the controller and I am having troubles, below is my view code:

<?php $i = 1; ?>
               <?php foreach ($this->cart->contents() as $items): ?>                
               <tr class="item first">
                   
                   <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
                   
                   <td class="thumb"><a href=""><img src="img/catalog/shopping-cart-thumb.jpg" alt="<?php echo $items['name']; ?>"/></a></td>
                   <td class="name"><a href=""><?php echo $items['name']; ?></a></td>
                   <td class="price"><?php echo $this->cart->format_number($items['price']); ?></td>
                   <td class="qnt-count">
                       <a class="incr-btn" href="#">-</a>
                       <?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '2', 'size' => '2')); ?>
                       <a class="incr-btn" href="#">+</a>
                   </td>
                   <?php $total = $this->cart->format_number($items['price'])*$items['qty']; ?>
                   <td class="total">QR <?php echo $total ?></td>
               </tr>
               <?php $i++; ?>
               <?php endforeach; ?>  

I have pretty much copied the code from the user guide but I am a little unsure on how to update the cart in the controller, I have started the below:

function update_cart() {
        
    $data = array (
        'rowid' => ,
        'qty'   => ,
    );
        
    $this->cart->update($data);
    redirect('/shop/cart', 'refresh');
} 

I just need help creating the multidimensional array from the data passed form the view…

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.