Merge branch 'fix-negative-basket' into 'develop'

Fixed : Negative basket threw a 500 error

See merge request ldc-web/projets/boutique-cnc-sable!51
This commit is contained in:
Vincent BRIDIER 2023-08-30 07:53:09 +00:00
commit 6d2c2ea95e
2 changed files with 11 additions and 2 deletions

View file

@ -71,10 +71,14 @@ class OrderTunnelController extends Controller
Cart::instance('panier');
$cart = Cart::content();
// Check that we have products in cart before saving.
if (count($cart) == 0) {
if (Cart::count() <= 0) {
// Then redirect to empty recap.
return redirect()->route('sales.recap');
return redirect()->route('sales.recap')->with(
'message',
'Le nombre total de produits dans cette commande ne peut être négatif.'
);
}
// Save.

View file

@ -8,6 +8,11 @@
@section('content')
<main id="command" class="container">
<div class="row m-0">
@if (\Session::has('message'))
<div class="w-100 text-red text-center">
{!! \Session::get('message') !!}
</div>
@endif
@include('partials.tunnel-stepper')
<article class="col mt-6 m-lg-0">
<p class="d-none d-lg-block title-regular text-center text-lg-end text-uppercase font-Barlow-extra-bold m-3">Récapitulatif de votre panier</p>