• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Cart Example

#12
[eluser]helmutbjorg[/eluser]
I believe the problem is with the update cart function. We need to get the total items for the cart outside the for loop function as the total_items() is being called each loop. If you set it to a variable first the total will not change during the loop (as you remove products).

Code:
function update_cart()
        {
                $total = $this->cart->total_items();
                for ($i = 1; $i <= $total; $i++)
                {
                        $item = $this->input->post($i);
                        $data = array(
                                'rowid' => $item['rowid'],
                                'qty' => $item['qty']
                        );
                        $this->cart->update($data);
                }
                redirect('shop/show_cart');
        }


Messages In This Thread
Basic Cart Example - by El Forum - 09-12-2009, 04:25 PM
Basic Cart Example - by El Forum - 09-12-2009, 04:26 PM
Basic Cart Example - by El Forum - 09-13-2009, 08:11 AM
Basic Cart Example - by El Forum - 09-13-2009, 08:31 AM
Basic Cart Example - by El Forum - 09-13-2009, 12:58 PM
Basic Cart Example - by El Forum - 09-30-2009, 09:00 PM
Basic Cart Example - by El Forum - 09-30-2009, 10:06 PM
Basic Cart Example - by El Forum - 10-01-2009, 07:22 AM
Basic Cart Example - by El Forum - 10-01-2009, 09:38 PM
Basic Cart Example - by El Forum - 10-07-2009, 10:58 AM
Basic Cart Example - by El Forum - 10-24-2009, 07:56 PM
Basic Cart Example - by El Forum - 10-24-2009, 10:07 PM
Basic Cart Example - by El Forum - 10-25-2009, 10:28 AM
Basic Cart Example - by El Forum - 10-25-2009, 12:55 PM
Basic Cart Example - by El Forum - 11-02-2009, 02:21 AM
Basic Cart Example - by El Forum - 11-04-2009, 04:19 AM
Basic Cart Example - by El Forum - 12-08-2009, 04:05 AM
Basic Cart Example - by El Forum - 12-09-2009, 01:19 PM
Basic Cart Example - by El Forum - 12-10-2009, 12:03 PM
Basic Cart Example - by El Forum - 12-10-2009, 12:14 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.