quick add to basket on shelves

This commit is contained in:
Ludovic CANDELLIER
2023-02-27 23:16:15 +01:00
parent 260eccc1f1
commit 808e60e41b
7 changed files with 53 additions and 14 deletions

View File

@@ -64,7 +64,6 @@ class CategoryController extends Controller
]), ]),
'tags' => TagGroups::getWithTagsAndCountOffers($category_id), 'tags' => TagGroups::getWithTagsAndCountOffers($category_id),
]; ];
// dump($data);
return view('Shop.Shelves.shelve', $data); return view('Shop.Shelves.shelve', $data);
} }

View File

@@ -200,6 +200,7 @@ class Articles
'product_id' => $article->product_id, 'product_id' => $article->product_id,
'product_name' => $article->product->name, 'product_name' => $article->product->name,
'parent_name' => trim(str_replace($article->product->name, '', $article->name)), 'parent_name' => trim(str_replace($article->product->name, '', $article->name)),
'offers' => $article->offers->toArray(),
]; ];
} }

View File

@@ -2,6 +2,8 @@
'id_card' => $model . '-basket', 'id_card' => $model . '-basket',
'title' => $title, 'title' => $title,
'class' => 'mb-3 ' . ($bgClass ?? null), 'class' => 'mb-3 ' . ($bgClass ?? null),
'classTitle' => 'mb-0',
'outline' => false,
]) ])
@include('components.form.select', [ @include('components.form.select', [

View File

@@ -1,14 +1,12 @@
<a href="{{ route('Shop.Articles.show', ['id' => $article['id'] ?? false ]) }}" class="green-dark"> <a href="{{ route('Shop.Articles.show', ['id' => $article['id'] ?? false ]) }}" class="green-dark">
<div class="card"> <div class="card">
<div class="content"> <div class="content">
<a href="#"> <div class="content-overlay"></div>
<div class="content-overlay"></div> <img class="content-image card-img-top" src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" alt="{{ $product_name }}">
<img class="content-image card-img-top" src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" alt="{{ $product_name }}"> <div class="content-details fadeIn-bottom">
<div class="content-details fadeIn-bottom"> <h3 class="content-title d-none"></h3>
<h3 class="content-title d-none"></h3> <p class="content-text">{!! $article['description'] !!}</p>
<p class="content-text">{!! $article['description'] !!}</p> </div>
</div>
</a>
</div> </div>
<div class="card-body p-2 pb-1"> <div class="card-body p-2 pb-1">
<div class="row card-title"> <div class="row card-title">
@@ -18,7 +16,7 @@
</div> </div>
</div> </div>
@include('Shop.Articles.partials.article_' . $product_type) @include('Shop.Articles.partials.article_' . $product_type)
<button type="button" class="btn btn-link bg-green text-white w-100" data-id=="{{ $article['id'] }}"> <button type="button" class="btn btn-link bg-green text-white w-100 basket" data-id="{{ $article['offers'][0]['id'] ?? false }}">
Ajout rapide Ajout rapide
</button> </button>
</div> </div>

View File

@@ -17,7 +17,7 @@
</div> </div>
</div> </div>
@foreach ($basket as $nature => $items) @foreach ($basket as $nature => $items)
<div class="row ml-1 mb-3 p-2 @if ($nature == 'semences') bg-yellow @else bg-green-dark @endif border rounded-lg"> <div class="row ml-1 mb-3 p-2 bg-green-light border rounded-lg">
<div class="col-12"> <div class="col-12">
<h2 style="font-size: 1.6em;" class="text-uppercase">{{ $nature }}</h2> <h2 style="font-size: 1.6em;" class="text-uppercase">{{ $nature }}</h2>
@foreach ($items as $item) @foreach ($items as $item)

View File

@@ -6,4 +6,43 @@
</div> </div>
@endforeach @endforeach
@endif @endif
</div> </div>
@push('js')
<script>
$('.basket').click(function() {
var offer_id = $(this).data('id');
var quantity = 1;
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()",
);
});
</script>
@endpush

View File

@@ -9,7 +9,7 @@
{!! $tools !!} {!! $tools !!}
</div> </div>
@endisset @endisset
<h3 class="card-title">{{ $title ?? false }}</h3> <h3 class="card-title {{ $classTitle ?? '' }}">{{ $title ?? false }}</h3>
@endisset @endisset
</div> </div>
@endif @endif
@@ -17,7 +17,7 @@
{{ $slot }} {{ $slot }}
</div> </div>
@isset($footer) @isset($footer)
<div class="card-footer"> <div class="card-footer {{ $classFooter ?? '' }}">
{{ $footer }} {{ $footer }}
</div> </div>
@endif @endif