点火器更新购物车


Codeigniter Update cart

我在CodeIgniter中的更新功能中遇到了问题。购物车没有更新,不明白为什么。你能帮我找到这个问题的解决方案吗?

这是我的更新功能

public function update($in_cart = null) {
        $data = $_POST;
        $this->cart->update($data);
        //show cart page
        redirect('cart','refresh');
    }

这是我在侧边栏中的表单.php

<form action="cart/update" method="POST">
                <table cellpadding="6" cellspacing="1" style="width:100%" border="0">
                  <tr>
                    <th>QTY</th>
                    <th>Item Description</th>
                    <th style="text-align:right">Item Price</th>
                  </tr>
                  <?php $i = 1; ?>
                  <?php foreach ($this->cart->contents() as $items) : ?>
                  <input type="hidden" name="<?php echo $i.'[rowid]'; ?>" value="<?php echo $items['rowid']; ?>" />
                  <tr>
                    <td><input type="text" style="color:black; text-align:center;margin-bottom:5px;" name="<?php $i.'[qty]'; ?>" value="<?php echo $items['qty']; ?>" maxlength="3" size="3"></td>
                    <td><?php echo $items['name']; ?></td>
                    <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
                  </tr>
                  <?php $i++; ?>
                <?php endforeach; ?>  
                  <tr>
                    <td></td>
                    <td class="right"><strong>Total</strong></td>
                    <td class="right" style="text-align:right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
                  </tr>
                </table>
                <br>
                <p><button class="btn btn-default" type="submit">Update Cart</button>
                <a class="btn btn-default" href="cart">Go to Cart</a></p>
              </form>

尝试使用 $this->input->post() 获取所有表单发布的数据。

https://ellislab.com/codeigniter/user-guide/libraries/input.html