@extends('Admin.layout') @section('content')
Edit Wholesale Offer
@csrf @php $selectedProductIds = array_map('strval', (array) old('product_id', $offer->product_ids ?? [])); $basePrice = (float) old('product_price', $offer->product_price); // Load all saved tiers. $offerTiers = old('offers', $offer->offer_tiers ?? []); // Backward compatibility for old records without offer_tiers. if (empty($offerTiers)) { $offerTiers = [ [ 'quantity' => $offer->quantity, 'offer_percentage' => $offer->offer_percentage, ], ]; } @endphp
{{-- Offer ID --}}
{{-- Products --}}
@foreach ($productGroups as $groupName => $groupProducts)
{{ $groupName }}
@foreach ($groupProducts as $product) @php $price = (float) ($product->variants->first()?->selling_price ?? 0); @endphp @endforeach @endforeach
@error('product_id') {{ $message }} @enderror @error('product_id.0') {{ $message }} @enderror
{{-- Selected Product Price --}}
{{-- Wholesale Offer Tiers --}}
Wholesale Offer Tiers
@foreach ($offerTiers as $index => $tier)
@error("offers.$index.quantity") {{ $message }} @enderror
@error("offers.$index.offer_percentage") {{ $message }} @enderror
@endforeach
@error('offers') {{ $message }} @enderror
{{-- Status --}}
@error('status') {{ $message }} @enderror
{{-- Submit --}}
@endsection