@extends('front.layout.master') @section('title', ($deal->title ?? __('Flash Deal')) . ' | ' . config('app.name')) @section('meta_tags') @if($deal->background_image && file_exists(public_path('images/flashdeals/' . $deal->background_image))) @endif @endsection @section('body') @php $cover = ($deal->background_image && file_exists(public_path('images/flashdeals/' . $deal->background_image))) ? url('images/flashdeals/' . $deal->background_image) : null; $isLive = strtotime($deal->end_date) >= time(); $startsLater = strtotime($deal->start_date) > time(); $itemsCount = ($deal->saleitems ?? collect())->count(); $currencySym = session()->get('currency')['value'] ?? ''; $currencyPos = session()->get('currency')['position'] ?? 'before'; // Currency may be stored as a Font Awesome class (e.g. "fa fa-dollar") rather than a glyph; // map common ones to Unicode so price strings stay plain text. $currencyGlyphMap = [ 'fa fa-dollar' => '$', 'fa-dollar' => '$', 'fa fa-rupee' => '₹', 'fa-rupee' => '₹', 'fa fa-inr' => '₹', 'fa fa-euro' => '€', 'fa-euro' => '€', 'fa fa-eur' => '€', 'fa fa-gbp' => '£', 'fa-gbp' => '£', 'fa fa-pound' => '£', 'fa fa-yen' => '¥', 'fa-yen' => '¥', 'fa fa-jpy' => '¥', 'fa fa-cny' => '¥', 'fa fa-bitcoin' => '₿', 'fa-bitcoin' => '₿', ]; $sym = $currencyGlyphMap[strtolower(trim((string) $currencySym))] ?? $currencySym; if (str_starts_with($sym, 'fa') || str_contains($sym, 'fa-')) $sym = '$'; // last-resort fallback $currencySym = $sym; $formatPrice = function ($amount) use ($currencySym, $currencyPos) { $n = number_format((float) $amount, 2); return $currencyPos === 'after' ? ($n . ' ' . $currencySym) : ($currencySym . ' ' . $n); }; @endphp {{-- Breadcrumb --}}
{{-- HERO --}}
@if($cover) @endif
@if($isLive && !$startsLater) {{ __('Live Now') }} @elseif($startsLater) {{ __('Upcoming') }} @else {{ __('Ended') }} @endif {{ $itemsCount }} {{ __('items') }}

{{ $deal->title }}

@if(!empty($deal->detail))
{!! $deal->detail !!}
@endif
{{ __('Starts') }}: {{ date('d M Y · h:i A', strtotime($deal->start_date)) }} {{ __('Ends') }}: {{ date('d M Y · h:i A', strtotime($deal->end_date)) }}
{{-- Countdown / status block --}}
@if($isLive && !$startsLater)
{{ __('Sale ends in') }}
@foreach(['days' => __('Days'), 'hours' => __('Hrs'), 'minutes' => __('Min'), 'seconds' => __('Sec')] as $key => $label)
--
{{ $label }}
@endforeach
@elseif($startsLater)
{{ __('Starts in') }}
@foreach(['days' => __('Days'), 'hours' => __('Hrs'), 'minutes' => __('Min'), 'seconds' => __('Sec')] as $key => $label)
--
{{ $label }}
@endforeach
@else
{{ __('Sale Ended') }}
{{ __('Browse the items below') }}
@endif
{{-- DEAL ITEMS GRID --}}
@if($itemsCount > 0)
@foreach($deal->saleitems as $item) @php $name = ''; $img = url('images/no-image.png'); $url = '#'; $des = ''; $basePrice = 0; $stock = 0; $minQty = 1; $cartAction = null; $isVariant = false; if (optional($item)->variant) { $isVariant = true; $variant = $item->variant; $product = $variant->products ?? null; if ($product) { $name = $product->name; $des = strip_tags($product->des ?? ''); $url = \App\Helpers\ProductUrl::getUrl($variant->id); if (optional($variant->variantimages)->main_image) { $thumbFile = $variant->variantimages->main_image; if (is_file(public_path('variantimages/thumbnails/' . $thumbFile))) { $img = url('variantimages/thumbnails/' . $thumbFile); } elseif (is_file(public_path('variantimages/' . $thumbFile))) { $img = url('variantimages/' . $thumbFile); } } $stock = $variant->stock ?? 0; $minQty = $variant->min_order_qty ?? 1; try { $get_product_data = new App\Http\Controllers\Api\MainController; $priceObj = $get_product_data->getprice($product, $variant)->getData(); $basePrice = ($priceObj->offerprice != 0) ? $priceObj->offerprice : $priceObj->mainprice; } catch (\Throwable $e) { $basePrice = $variant->price ?? 0; } } } elseif (optional($item)->simple_product) { $sp = $item->simple_product; $name = $sp->product_name; $des = strip_tags($sp->product_detail ?? ''); $url = route('show.product', ['id' => $sp->id, 'slug' => $sp->slug]); if ($sp->thumbnail && file_exists(public_path('images/simple_products/' . $sp->thumbnail))) { $img = url('images/simple_products/' . $sp->thumbnail); } $stock = $sp->stock ?? 0; $minQty = $sp->min_order_qty ?? 1; $basePrice = ($sp->offer_price ?? 0) != 0 ? $sp->offer_price : ($sp->price ?? 0); } // Apply campaign discount $discount = (float) ($item->discount ?? 0); $discountType = $item->discount_type ?? 'flat'; if ($discountType === 'upto') { $effectiveDiscount = rand(0, (int) $discount); } else { $effectiveDiscount = $discount; } $dealPrice = $basePrice - ($basePrice * $effectiveDiscount / 100); @endphp
@if($discount > 0) @if($discountType === 'upto') {{ __('Up to') }} −{{ (int) $discount }}% @else −{{ (int) $discount }}% @endif @endif @if($stock <= 0)
{{ __('Out of stock') }}
@endif {{ $name }}
{{ $name }}
{{ $formatPrice($dealPrice * ($conversion_rate ?? 1)) }} @if($discount > 0 && $basePrice > 0) {{ $formatPrice($basePrice * ($conversion_rate ?? 1)) }} @endif
@if($isLive && !$startsLater && $stock > 0) @if($isVariant && optional($item->variant->products)->id)
@csrf
@elseif(!$isVariant && optional($item->simple_product)->id)
@csrf
@endif @elseif($startsLater) @elseif(!$isLive) {{ __('View product') }} @else @endif
@endforeach
@else

{{ __('No products in this deal') }}

{{ __('Items have not been added to this campaign yet.') }}

← {{ __('Back to all deals') }}
@endif
@endsection @section('script') @endsection