[eluser]Bus Pants[/eluser]
So I am using the cart library, both the cart and session libraries are autoloaded in the config file. My session data is stored in a db table and it is there when I look.
When I add a new item to the cart I am redirected to the cart and the items show up. If I print_r($this->cart->contents()) at this point I get the correct output.
I click the Checkout button which goes to a form you fill out with your credit card info...
if I print_r($this->cart->contents()) at the bottom of the form it still shows up.
When I submit that form it goes to my checkout controller and for testing I just echo the cart info, and at this point my cart is empty but the info is still in the db...
print_r($this->cart->contents()) just echos Array( ) and $this->cart->total() and $this->cart->total_items() both echo as 0.
What could be causing this?
This is my cart controller which successfully sends the cart data to the view:
Code:
class Cart extends CI_Controller {
public function index() {
// load the asset helper access css. scripts and images
$this->load->helper('asset');
// load gloabal css file into $css variable
$data['css'] = css_asset('style.css');
// load jQuery library into $jquery variable
$data['jquery_main'] = js_asset('jquery-1.7.1.min.js');
// set page value for navigation background image toggle
$data['page'] = "shop";
$data['cart_items'] = $this->cart->contents();
$data['total'] = $this->cart->total();
// load the head, body and footer view templates
$this->load->view('header', $data);
$this->load->view('cart');
$this->load->view('footer');
}
}
on the view I just loop through the cart and it works:
Code:
<?php foreach ($cart_items as $item) {
echo $item['id'];
etc.
etc.
} ?>
But in my Checkout controller if I just echo out the cart data, either with print_r, var_dump or looping through it like above, I get nothing...
Code:
echo "$" . $this->cart->total();
exit;
// just echos $0
Where is my cart data?
What's in the db looks like this:
Code:
a:2:{s:9:"user_data";s:0:"";s:13:"cart_contents";a:3:{s:32:"c4ca4238a0b923820dcc509a6f75849b";a:6:{s:5:"rowid";s:32:"c4ca4238a0b923820dcc509a6f75849b";s:2:"id";s:1:"1";s:3:"qty";s:1:"1";s:5:"price";s:6:"120.00";s:4:"name";s:23:"Calypso Sunnies - Black";s:8:"subtotal";d:120;}s:11:"total_items";i:1;s:10:"cart_total";d:120;}}