fix: replace hardcoded nature keys with dynamic foreach in article add-to-basket
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
@php
|
||||
// Check if article is not visible OR has no offers at all
|
||||
$hasNoOffers = empty($article['offers']['semences'] ?? false)
|
||||
&& empty($article['offers']['plants'] ?? false)
|
||||
&& empty($article['offers']['legumes'] ?? false)
|
||||
&& empty($article['offers']['marchandise'] ?? false);
|
||||
$hasNoOffers = empty($article['offers'] ?? false) || !array_filter($article['offers']);
|
||||
$shouldShowComingSoon = !($article['visible'] ?? true) || $hasNoOffers;
|
||||
@endphp
|
||||
|
||||
@@ -19,41 +16,16 @@
|
||||
</div>
|
||||
@else
|
||||
{{-- Display normal offers for visible articles with available offers --}}
|
||||
@if ($article['offers']['semences'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['semences'],
|
||||
'title' => 'Semences',
|
||||
'model' => 'semences',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['plants'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['plants'],
|
||||
'title' => 'Plants',
|
||||
'model' => 'plants',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['legumes'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['legumes'],
|
||||
'title' => 'Légumes',
|
||||
'model' => 'legumes',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['marchandise'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['marchandise'],
|
||||
'title' => 'Marchandises',
|
||||
'model' => 'marchandise',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@foreach ($article['offers'] as $natureKey => $natureOffers)
|
||||
@if (!empty($natureOffers))
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $natureOffers,
|
||||
'title' => ucfirst($natureKey),
|
||||
'model' => $natureKey,
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@include('load.basket')
|
||||
|
||||
Reference in New Issue
Block a user