Files
opensem/resources/views/Shop/Articles/partials/ArticleAddBasket.blade.php
Ludovic CANDELLIER 0feebca7e0 fixes
2022-12-22 01:09:11 +01:00

79 lines
2.1 KiB
PHP

@if ($article['offers']['semences'] ?? false)
@include('Shop.Articles.partials.addBasket', [
'data' => $article['offers']['semences'],
'title' => 'Semence',
'model' => 'semences',
'bgClass' => 'bg-yellow',
])
@endif
@if ($article['offers']['plants'] ?? false)
@include('Shop.Articles.partials.addBasket', [
'data' => $article['offers']['plants'],
'title' => 'Plant',
'model' => 'plants',
'bgClass' => 'bg-green-dark',
])
@endif
@if ($article['offers']['legumes'] ?? false)
@include('Shop.Articles.partials.addBasket', [
'data' => $article['offers']['legumes'],
'title' => 'Légume',
'model' => 'legumes',
])
@endif
@push('js')
<script>
$('.basket').click(function() {
var type = $(this).data('type');
var offer_id = $('#' + type + '-offer_id').find('option:selected').val();
var quantity = $('#' + type + '-quantity').val();
var data = {
'offer_id': offer_id,
'quantity': quantity,
};
var buttons = {
cancel: {
label: '{{ __('Continuer mes achats') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('Commander') }}',
className: 'btn-success',
callback: function() {
window.location = "{{ route('Shop.Basket.basket') }}";
}
},
};
openModal(
'Ajout dans le panier',
'basket-form',
"{{ route('Shop.Basket.modalBasket') }}/" + offer_id + '/' + quantity,
"{{ route('Shop.Orders.order') }}",
false,
false,
true,
buttons,
"refreshBasketTop()",
);
});
function setPrice(model) {
var offer_id = $('#' + model + '-offer_id').find('option:selected').val();
var quantity = $('#' + model + '-quantity').val();
var data = {
'offer_id': offer_id,
'quantity': quantity,
};
$.post('{{ route("Shop.Basket.getPrice") }}', data, function(data) {
$('#' + model + '-price').html(data);
});
}
</script>
@endpush