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