Welcome Guest, Not a member yet? Register   Sign In
A simple problem with CodeIgniter Cart Library
#1

[eluser]dojolab[/eluser]
Hello, I have e simple problem with CodeIgniter Cart Library; this is my 'add' method of my Cart Controller.
Code:
function add() {
                            
    // CART ID (FOR DB STORAGE)
    if($this->session->userdata('cart_sid') == FALSE) {
        
        $cart_sid = md5(time()); // cart id.

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

        $this->session->set_userdata($data);
    }
    

    $data =
                array(
    
                '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')

        );

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

}

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!
#2

[eluser]LuckyFella73[/eluser]
I don't know if that is the problem (would be helpful to see your "insert" and
"add" method) but in case
Code:
$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?
#3

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

Sad




Theme © iAndrew 2016 - Forum software by © MyBB