Add variations, slider, fix cart ...
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
@if ($article['offers']['semences'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['semences'],
|
||||
'title' => 'Semence',
|
||||
'model' => 'semences',
|
||||
])
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['plants'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['plants'],
|
||||
'title' => 'Plant',
|
||||
'model' => 'plants',
|
||||
])
|
||||
@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,
|
||||
};
|
||||
$.post('{{ route("Shop.Basket.addBasket") }}', data, function() {
|
||||
console.log('ici');
|
||||
});
|
||||
console.log(type);
|
||||
console.log(offer_id);
|
||||
console.log(quantity);
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
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
|
||||
51
resources/views/Shop/Articles/partials/addBasket.blade.php
Normal file
51
resources/views/Shop/Articles/partials/addBasket.blade.php
Normal file
@@ -0,0 +1,51 @@
|
||||
@component('components.card', [
|
||||
'id_card' => $model . '-basket',
|
||||
'title' => $title,
|
||||
'class' => 'mb-3',
|
||||
])
|
||||
|
||||
@include('components.form.select', [
|
||||
'name' => 'offer_id',
|
||||
'id_name' => $model . '-offer_id',
|
||||
'list' => collect($data)->pluck('name', 'id')->toArray(),
|
||||
'class' => 'select2 mb-2',
|
||||
])
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
@include('components.form.inputs.number', [
|
||||
'name' => 'quantity',
|
||||
'id_name' => $model . '-quantity',
|
||||
'value' => 1,
|
||||
])
|
||||
</div>
|
||||
<div class="col-8 text-right">
|
||||
<span id="{{ $model }}-price" style="font-size:2em; font-weight: 600;">
|
||||
{{ $data[0]['prices'][0]['price_taxed'] }}
|
||||
</span>
|
||||
€ TTC
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('components.form.button', [
|
||||
'metadata' => 'data-type=' . $model,
|
||||
'class' => 'btn-success basket w-100 ' . $model,
|
||||
'txt' => 'Ajouter au panier',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endcomponent
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('#{{ $model }}-quantity').change(function() {
|
||||
setPrice('{{ $model }}');
|
||||
});
|
||||
$('#{{ $model }}-offer_id').change(function() {
|
||||
setPrice('{{ $model }}');
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user