No stock validation existed in the ordering flow, allowing customers to order more items than available. Cap quantity to ``stock_current`` in ``Baskets::getBasketData()`` when adding to cart. Add ``min=1`` and ``max=stock`` attributes on the basket quantity input, with JS clamping in the change handler. Verify stock again in ``Shop\OrderController::store()`` before saving the order as a race-condition safeguard.
31 lines
1.4 KiB
PHP
31 lines
1.4 KiB
PHP
<div class="row basket-row mb-3" id="basket_offer-{{ $item['id'] }}" data-id={{ $item['id'] }}>
|
|
<div class="col-2 text-center">
|
|
<img src="{{ $item['image'] }}" class="img-fluid rounded">
|
|
</div>
|
|
<div class="col-10">
|
|
<h3 style="font-size: 1.4em;">{{ $item['name'] }}</h3>
|
|
@if ($item['latin'] ?? false)
|
|
{{ $item['latin'] }}<br>
|
|
@endif
|
|
{{ $item['variation'] }}<br/>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<span class="basket-price">{{ number_format($item['price'],2) }}</span> € / unité
|
|
</div>
|
|
<div class="col-2">
|
|
@include('components.form.inputs.number', [
|
|
'name' => 'quantity',
|
|
'value' => $item['quantity'],
|
|
'class' => 'basket-quantity',
|
|
'data_id' => $item['id'],
|
|
'min' => 1,
|
|
'max' => $item['stock'] ?? false,
|
|
])
|
|
</div>
|
|
<div class="col-4 text-right" style="font-size: 2em;" id="basket_total-{{ $item['id'] }}">
|
|
<span class="basket-total-row">{{ number_format($item['quantity'] * $item['price'],2) }}</span> €
|
|
<i class="btn btn-warning fa fa-trash basket-delete ml-3 mb-2" data-id={{ $item['id'] }}></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |