bumbummen99 / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
503 stars 235 forks source link

Cart::instance('default')->destroy() cleans cart when using form but not directly in controller #69

Closed jordantsap closed 3 years ago

jordantsap commented 4 years ago

I use "bumbummen99/shoppingcart": "^2.8", with "laravel/framework": "5.8.*". The problem is exactly what the title say I have a form in my header like below:

`

  • {{ csrf_field() }}
                  </li>

    `---------------------------------------------`` which works as intended and delete cart products per will.

    The cart.clean function is:

    public function clean() { Cart::instance('default')->destroy(); $notification = array( 'message' => __('alerts.cartclean'), 'alert-type' => 'success' ); return redirect()->back()->with($notification); }

    but in my checkoutcontroller i use: Cart::instance('default')->destroy(); or Cart::destroy(); , i have tryed both

    in order to clean the cart products after the order is submitted and sends the order email to the customer

    Can someone help me with this??

  • Sartoric commented 4 years ago

    I do exactly the same in the controller but I've never had issue

    Cart::destroy(); Cart::erase($cartId);

    There should be something wrong/strange in the controller code as you say that is working correctly while called from the form. Is the public function clean() inside the same controller ? Are you doing something with session in the controller ?

    jordantsap commented 4 years ago

    It's a website that i developed a long time ago, imagine it uses laravel 5.8. What laravel and shoppingcart version do you use??

    github-actions[bot] commented 3 years ago

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days