Crinsane / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
3.67k stars 1.73k forks source link

cart only works after "main" is instantiated. #55

Closed prajwolonta closed 10 years ago

prajwolonta commented 10 years ago

Hi .. I have this code : Cart::instance($instance)->associate('Product')->add(array('id' => $id, 'name' => $name, 'qty' => $qty, 'price' => $price));

if the instance is 'wishlist' the very first time it does not work.. the wishlist instance is not save. But if the instance is "main" first time and second time its "wishlist" then only the wishlist is instantiated.

How can i fix this?

prajwolonta commented 10 years ago
public function postAddToCart() {
    $instance = Input::get('instance');
    //dd($instance);
    $id = Input::get('product_id');
    $name = Input::get('product_name');
    $qty = Input::get('product_qty');
    $price = Input::get('product_price');
    Cart::instance($instance)->associate('Product')->add(array('id' => $id, 'name' => $name, 'qty' => $qty, 'price' => $price));
    return Redirect::to(URL::previous())
                    ->with('message', 'Added to cart.');
}

THis is my code for adding as a cart or wishlist.

Crinsane commented 10 years ago

I can't seem to reproduce this. Which session driver are you using?

prajwolonta commented 10 years ago

im using laravel default driver file.