Add merchandise, fix articletosell with src for images

This commit is contained in:
Ludovic CANDELLIER
2022-04-14 23:20:09 +02:00
parent 2f77b5fc23
commit 165262abfa
14 changed files with 69 additions and 23 deletions

View File

@@ -4,7 +4,7 @@
@section('content')
@if ($basket)
<div class="row m-0">
<div class="row">
<div class="col-8">
<div class="row mb-3">
<div class="col-4">
@@ -17,7 +17,7 @@
</div>
</div>
@foreach ($basket as $nature => $items)
<div class="row mb-3 p-2 bg-green-light">
<div class="row mb-3 p-2 bg-green-light border">
<div class="col-12">
<h2 style="font-size: 1.6em;">{{ ucfirst($nature) }}</h2>
@foreach ($items as $item)
@@ -73,19 +73,28 @@
calculateTotal();
$('.basket-quantity').change(function() {
calculatePrice($(this).parents('.basket-row'));
var offer_id = $(this).data('id');
quantity = $('.basket-quantity').value;
addBasket(offer_id, quantity, function() {
calculatePrice($(this).parents('.basket-row'));
calculateTotal();
});
});
$('.basket-delete').click(function() {
var offer_id = $(this).data('id');
var data = {offer_id: offer_id, quantity: 0};
$.post("{{ route('Shop.Basket.addBasket') }}", data, function() {
addBasket(offer_id, 0, function() {
$('#basket_offer-' + offer_id).remove();
calculateTotal();
});
});
}
function addBasket(offer_id, quantity, callback) {
var data = {offer_id: offer_id, quantity: 0};
$.post("{{ route('Shop.Basket.addBasket') }}", data, callback);
}
function calculatePrice($that) {
var quantity = $that.find('.basket-quantity').val();
var price = $that.find('.basket-price').text();
@@ -103,6 +112,7 @@
});
$('#basket-total').html(fixNumber(total));
calculateTotalShipped();
refreshBasketTop();
return total;
}

View File

@@ -14,13 +14,12 @@
'name' => 'quantity',
'value' => $item['quantity'],
'class' => 'basket-quantity',
'data_id' => $item['id'],
])
</div>
<div class="col-3 text-right" style="font-size: 2em;" id="basket_total-{{ $item['id'] }}">
<div class="col-4 text-right" style="font-size: 2em;" id="basket_total-{{ $item['id'] }}">
<span class="basket-total-row">{{ $item['quantity'] * $item['price'] }}</span>
</div>
<div class="col-1 text-center">
<i class="btn fa fa-fw fa-trash basket-delete" style="font-size: 1.6em;" data-id={{ $item['id'] }}></i>
<i class="btn btn-success fa fa-trash basket-delete ml-3 mb-2" data-id={{ $item['id'] }}></i>
</div>
</div>
</div>