fix: make the selected channel apply changes to product each time
This commit is contained in:
@@ -48,35 +48,53 @@
|
||||
|
||||
</div>
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
@if (config('app.debug') && ($article['current_sale_channel'] ?? false))
|
||||
@if (config('app.debug') && !empty($article['available_sale_channels']))
|
||||
<div class="alert alert-info p-2 mb-3">
|
||||
<strong>Canal actif :</strong>
|
||||
{{ $article['current_sale_channel']['name'] ?? 'N/A' }}
|
||||
<span class="d-block small text-muted">
|
||||
ID {{ $article['current_sale_channel']['id'] ?? '–' }} · Code {{ $article['current_sale_channel']['code'] ?? '–' }}
|
||||
</span>
|
||||
@if (!empty($article['available_sale_channels']))
|
||||
<hr class="my-2">
|
||||
<strong class="d-block">Offres disponibles dans :</strong>
|
||||
<ul class="list-unstyled mb-0 small">
|
||||
@foreach ($article['available_sale_channels'] as $channel)
|
||||
<li class="d-flex justify-content-between align-items-start">
|
||||
<span>
|
||||
<strong class="d-block">Offres :</strong>
|
||||
<ul class="list-unstyled mb-0 small">
|
||||
@php
|
||||
$currentSaleChannelId = $article['current_sale_channel']['id'] ?? null;
|
||||
@endphp
|
||||
@foreach ($article['available_sale_channels'] as $channel)
|
||||
@php
|
||||
$isCurrentChannel = $currentSaleChannelId === $channel['id'];
|
||||
$priceTaxed = $channel['price_taxed'] ?? null;
|
||||
$quantity = $channel['quantity'] ?? null;
|
||||
$offerStock = $channel['offer_stock_current'] ?? null;
|
||||
$offerIsActive = $channel['offer_is_active'] ?? false;
|
||||
$offerHasStock = $channel['offer_has_stock'] ?? null;
|
||||
$highlightStyle = $isCurrentChannel ? 'background-color: rgba(0, 0, 0, 0.06);' : '';
|
||||
$nameClass = ($offerIsActive && $offerHasStock !== false) ? '' : 'text-muted';
|
||||
$flags = [];
|
||||
if (! $offerIsActive) {
|
||||
$flags[] = 'inactive';
|
||||
}
|
||||
if ($offerHasStock === false) {
|
||||
$flags[] = 'no-stock';
|
||||
}
|
||||
@endphp
|
||||
<li style="{{ $highlightStyle }}">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<span class="{{ $nameClass }}">
|
||||
• {{ $channel['name'] }}
|
||||
<span class="d-block text-muted" style="font-size: 0.85em; padding-left: 0.9em;">code {{ $channel['code'] }}</span>
|
||||
<span class="d-block text-muted" style="font-size: 0.85em; padding-left: 0.9em;">
|
||||
Code {{ $channel['code'] }}{!! $flags ? ' · <strong class="text-dark">'.implode('</strong> · <strong class="text-dark">', $flags).'</strong>' : '' !!}
|
||||
</span>
|
||||
</span>
|
||||
@if (isset($channel['price_taxed']))
|
||||
<span class="ml-2 text-nowrap text-right">
|
||||
{{ number_format($channel['price_taxed'], 2, ',', ' ') }} € TTC
|
||||
@if (! empty($channel['quantity']))
|
||||
<span class="d-block text-muted" style="font-size: 0.85em;">Qté min. {{ $channel['quantity'] }}</span>
|
||||
@if ($priceTaxed !== null)
|
||||
<span class="ml-2 text-nowrap text-right {{ $nameClass }}">
|
||||
{{ number_format($priceTaxed, 2, ',', ' ') }} € TTC
|
||||
@if (! empty($quantity))
|
||||
<span class="d-block text-muted" style="font-size: 0.85em;">Qté min. {{ $quantity }}</span>
|
||||
@endif
|
||||
</span>
|
||||
@else
|
||||
<span class="ml-2 text-muted">–</span>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@include('Shop.Articles.partials.ArticleAddBasket')
|
||||
|
||||
@@ -157,6 +157,12 @@
|
||||
? xhr.responseJSON.message
|
||||
: "{{ __('Une erreur est survenue lors de l\'enregistrement du canal de vente préféré.') }}";
|
||||
|
||||
console.error('Sale channel update failed', {
|
||||
status: xhr.status,
|
||||
response: xhr.responseJSON || xhr.responseText,
|
||||
selectedSaleChannel
|
||||
});
|
||||
|
||||
alert(message);
|
||||
|
||||
if (currentSaleChannelId) {
|
||||
|
||||
Reference in New Issue
Block a user