CodeIgniter Forums

Full Version: A simple problem with CodeIgniter Cart Library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hello, I have e simple problem with CodeIgniter Cart Library; this is my 'add' method of my Cart Controller.
function add() {
    if($this->session->userdata('cart_sid') == FALSE) {
        $cart_sid = md5(time()); // cart id.

       $data = array(
            'cart_sid'    =>    (string) $cart_sid


    $data =
                'id'    =>    (string) $this->input->post('product_code'),
                'qty'    =>    (int) $this->input->post('product_quantity'),
                'price'    =>    (float) $this->input->post('product_price'),
                'name'    =>    (string) $this->input->post('product_name')




Where is the problem?

When I added the FIRST product/item to cart there is no problem.
When I added the SECOND product/item to cart (by add method), the item is not inserted...
Why? The POST debug works correctly!

Thanks for reply!

El Forum

I don't know if that is the problem (would be helpful to see your "insert" and
"add" method) but in case
$this->session->userdata('cart_sid') == FALSE
you set an array that is overwritten after the if condition. I don't
know if you need that information to be passed to your methods?

El Forum

Thanks for reply.
The problem is not the rewritten of array ($data); i have used debug for test it.