在codeigniter中购物,更改产品数量和更新购物车[关闭]

Can anybody post the code for updating cart. I mean to say if my cart quantity changes to any quantity like 2 or 3 cart should update and it should reflect in subtotal of cart also

use $this->cart->update() to update items in the cart.

$data = array(
               'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
               'qty'   => 3
            );

$this->cart->update($data); 

For a multi-dimensional array

$data = array(
               array(
                       'rowid'   => 'b99ccdf16028f015540f341130b6d8ec',
                       'qty'     => 3
                    ),
               array(
                       'rowid'   => 'xw82g9q3r495893iajdh473990rikw23',
                       'qty'     => 4
                    ),
               array(
                       'rowid'   => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
                       'qty'     => 2
                    )
            );

$this->cart->update($data);