簡體   English   中英

無法更新 Codeigniter 購物車中的第一個產品數量

[英]Cant update first product quantity in Codeigniter Cart

我似乎無法在 Codeigniter 上更新我的購物車中的第一個產品數量。

這是購物車。php 代碼:

<?php
$cartdata = $this->cart->contents();
foreach ($cartdata as $data):
    ?>
    <form method="POST" action="<?php echo base_url();?>wholesaler/updatequantity/">
<tr>
    <td class="product__thumbnail">
        <a href="#">
            <img src="<?php echo base_url().'uploads/products/'.$data['image'];?>" alt="">
        </a>
    </td>
    <input class="form-control" name="rowid" value="<?php echo $data['rowid'];?>" type="hidden">
    <td class="product__name">
        <a href="#"><?php echo $data['name']; ?></a>
        <br><br>
        <small><?php echo $data['sellername']; ?></small>
    </td>
    <td class="product__price">
        <div class="price">
            <span class="new__price">RWF <?php echo $data['price']; ?></span>
        </div>
    </td>          
    <td class="product__quantity">
        <div class="input-counter">
            <div>
                <span class="minus-btn" id="decrease" onclick="decreaseValue()">
                    <img src="https://img.icons8.com/android/24/000000/minus.png"/>
                </span>
                <input type="number" id="number" min="0" name="qty" placeholder="<?php echo $data['qty'];?>" class="counter-btn" />
                
                <span class="plus-btn" id="increase" onclick="increaseValue()">
                    <img src="https://img.icons8.com/android/24/000000/plus.png"/>
                </span>
            </div>
        </div>
    </td>
    <td>
    <button type="submit" class="btn btn-secondary btn-sm">Update Quantity</button>
    </td>
    </form>
    <td class="product__subtotal">
        <div class="price">
            <span class="new__price">RWF <?php echo $data['subtotal']; ?></span>
        </div>
        <a href="<?php echo base_url().'wholesaler/deletecart/'.$data['rowid'];?>" class="remove__cart-item">
            <svg>
            <img src="https://img.icons8.com/ios-filled/24/000000/delete-forever.png"/>
            </svg>
        </a>
    </td>
</tr>
<?php endforeach ;?>

這是我的 controller:

function updatequantity(){
    $data = array(
    'rowid' => $this->input->post('rowid'),
    'qty'   => $this->input->post('qty'),
    );
    $this->cart->update($data);  
    $this->load->view('wholesale/cart');
}

所以我可以為其他產品更新它只是第一個,當我按下更新按鈕時,它甚至似乎不是 go 到我的更新 function。

請幫忙。 這是我的屏幕截圖

找到了我的問題的解決方案,問題是我實際上將 updatequantity 表單嵌入到表單中。

在這里找到解決方案: https://www.experts-exchange.com/questions/28410855/Button-in-first-row-of-html-table-does-not-work.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM