duankanyi6539 2016-06-15 21:52
浏览 25

在Codeigniter中向购物车添加数量

So I'm not sure whether there are similar questions elsewhere and this is my problem when change or add another qty on same item.

Add item with some qty to cart

For first, i add some items with some qty to my cart

After inserting item to cart then it will show in my cart list

After inserting item to cart, then the item will show in my cart list. It's look fine

After that, i add same item but now with different another quantity number (and the problem start...)

Then, i add same item but now with another qty

The problem now show here in my cart list. The quatity in my stock is only 5. When i add in first time it's look fine, but when i try to input with another quatity (in this case is 6) it will add to my cart and now my quatity buy is 11. This is over from my stock.

New cart list showing

This is my controller to add item to cart

function addToCart()
{
    $data = array(
        'id'    => @$this->input->post('registerNum'),
        'qty'   => @$this->input->post('buyQty'),
        'price' => @$this->input->post('priceEach'),
        'name'  => @$this->input->post('itemName'),
    );
    $this->cart->insert($data);
    redirect('admin/transaction/add');
}

So, anyone can help me with this problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 AT89C51控制8位八段数码管显示时钟。
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口