@extends('layouts.app') @php $currentLocale = app()->getLocale(); $translation = $product->translate($currentLocale); // $currentPrice = $product->current_price; // ✅ NEW: Use current_price accessor $primaryImage = $product->images->where('is_primary', true)->first() ?: $product->images->first(); @endphp @section('title', $translation->meta_title ?: $translation->name) @section('meta_description', $translation->meta_description ?: $translation->short_description) @section('meta_keywords', $translation->meta_keywords) @push('meta') {{-- ✅ ENHANCED: Better SEO meta tags --}} @if($translation->meta_keywords) @endif {{-- ✅ NEW: Product-specific meta tags --}} @if($product->brand) @endif {{-- Enhanced Open Graph --}} @if($primaryImage) @endif {{-- Product-specific Open Graph --}} @endpush @push('structured_data') {{-- ✅ ENHANCED: Rich structured data --}} {{-- Breadcrumb structured data --}} @endpush @push('styles') @endpush @section('content') {{-- ✅ NEW: Product Hero Section --}}
{{-- ✅ ENHANCED: Product Gallery --}}
{{-- ✅ ENHANCED: Product Info --}}
{{-- ✅ NEW: Product Badges --}}
@if($product->is_featured) {{ __('Featured') }} @endif @if($availabilityInfo['is_sale_active'] ?? false) {{ __('Sale') }} @endif @if($product->created_at->diffInDays() < 7) {{ __('New') }} @endif @if($product->cod_eligible) {{ __('COD Available') }} @endif

{{ $translation->name }}

{{-- ✅ ENHANCED: Product Meta --}}
{{ __('SKU') }}: {{ $product->sku }}
@if($product->brand)
{{ __('Brand') }}: {{ $product->brand }}
@endif @if($product->model)
{{ __('Model') }}: {{ $product->model }}
@endif
{{ number_format($productStats['views_count']) }} {{ __('views') }}
{{-- ✅ NEW: Short Description --}} @if($translation->short_description)

{{ $translation->short_description }}

@endif {{-- ✅ ENHANCED: Price Section with Sale Info --}} @php $basePrice = $product->sale_price ?: $product->price; $vatAmount = $basePrice * ($product->tax_rate/100); $customerPrice = $basePrice + $vatAmount; @endphp
{{ number_format($customerPrice, 2) }} {{ __('SAR') }}
@if($product->sale_price && $product->isSaleActive())
{{ number_format($product->price, 2) }} {{ __('SAR') }} -{{ $product->discount_percentage }}% {{ __('You save') }}: {{ number_format($product->price - $product->sale_price, 2) }} {{ __('SAR') }}
{{-- ✅ NEW: Sale Timer --}} @if($product->sale_ends_at)
{{ __('Sale ends') }}: {{ $product->sale_ends_at->format('M d, Y H:i') }}
@endif @endif
{{-- ✅ ENHANCED: Stock Status --}}
@switch($availabilityInfo['stock_status']) @case('in_stock') {{ __('In Stock') }} @if($availabilityInfo['quantity_available']) ({{ $availabilityInfo['quantity_available'] }} {{ __('available') }}) @endif @break @case('low_stock') {{ __('Low Stock') }} - {{ __('Only') }} {{ $availabilityInfo['quantity_available'] }} {{ __('left') }}! @break @case('out_of_stock') {{ __('Out of Stock') }} @break @endswitch
{{-- ✅ NEW: Product Stats --}}
{{ number_format($productStats['views_count']) }}
{{ __('Views') }}
{{ $productStats['times_purchased'] }}
{{ __('Sold') }}
{{ $productStats['in_wishlist_count'] }}
{{ __('In Wishlists') }}
{{ $reviewsSummary['average_rating'] }}
{{ __('Rating') }}
{{-- ✅ ENHANCED: Product Actions --}}
{{-- ✅ NEW: Additional Info --}}
{{ __('Categories') }}: @foreach($product->categories as $category) {{ $category->translate($currentLocale)->name }} @endforeach
@if($product->cod_eligible)
{{ __('Cash on Delivery Available') }}
@endif
{{-- ✅ ENHANCED: Product Details Tabs --}}
{{-- Description Tab --}}
{!! nl2br(e($translation->description)) !!}
{{-- Features Tab --}} @if($translation->features)
    @foreach(array_filter(explode("\n", $translation->features)) as $feature)
  • {{ trim(str_replace(['•', '-', '*'], '', $feature)) }}
  • @endforeach
@endif {{-- Specifications Tab --}} @if($translation->specifications)
@foreach(array_filter(explode("\n", $translation->specifications)) as $spec) @if(strpos($spec, ':') !== false) @php [$key, $value] = explode(':', $spec, 2); @endphp @endif @endforeach
{{ trim($key) }} {{ trim($value) }}
@endif {{-- ✅ NEW: Reviews Tab (Placeholder) --}}

{{ $reviewsSummary['average_rating'] }}

@for($i = 1; $i <= 5; $i++) @endfor

{{ $reviewsSummary['total_reviews'] }} {{ __('reviews') }}

@foreach([5,4,3,2,1] as $stars)
{{ $stars }}
{{ $reviewsSummary['rating_distribution'][$stars] }}
@endforeach

{{ __('Review system coming soon!') }}

{{-- ✅ ENHANCED: Related Products --}} @if($relatedProducts->isNotEmpty()) @endif {{-- ✅ FIXED: Recently Viewed Products --}} @if($recentlyViewed->isNotEmpty())

{{ __('Recently Viewed') }}

@foreach($recentlyViewed->take(4) as $viewedItem) @php // ✅ FIX: Handle the enhanced array structure $viewedProduct = $viewedItem['product'] ?? $viewedItem; $viewedTranslation = $viewedItem['translation'] ?? $viewedProduct->translate($currentLocale); $viewedImage = $viewedProduct->images->where('is_primary', true)->first() ?: $viewedProduct->images->first(); @endphp
@if($viewedImage) {{ $viewedTranslation->name }} @endif
{{ Str::limit($viewedTranslation->name, 30) }}
{{ number_format($viewedProduct->current_price, 2) }} {{ __('SAR') }} {{-- ✅ NEW: Show when it was viewed --}} @if(isset($viewedItem['viewed_at']))
{{ __('Viewed') }} {{ $viewedItem['viewed_at']->diffForHumans() }} @endif
@endforeach
@endif
{{-- ✅ NEW: Image Zoom Modal --}} @endsection @push('scripts') @endpush