@extends('frontend::layouts.master') @php $assetPath = 'frontend_assets'; $langCode = session('lang_code', 'en'); @endphp @section('content')
Back
@php $galleryIds = $product->gallery ? explode(',', $product->gallery) : []; $allImageIds = $galleryIds; if ($product->thumbnail && !in_array($product->thumbnail, $allImageIds)) { array_unshift($allImageIds, $product->thumbnail); } $galleryAssets = \Modules\FileManager\Entities\FileUpload::whereIn('id', $allImageIds)->get()->keyBy('id'); // Drop images whose record or file is missing so broken images never render $allImageIds = array_values(array_filter($allImageIds, fn($id) => uploadedAssetExists($galleryAssets[$id] ?? null))); @endphp
@foreach ($allImageIds as $index => $imgId) @php $asset = $galleryAssets[$imgId] ?? null; $isVid = $asset && str_contains($asset->file_type, 'video'); $fileUrl = uploadedAsset($imgId); $thumbUrl = $isVid ? asset($assetPath . '/images/image-placeholder.png') : $fileUrl; @endphp
Thumb {{ $index + 1 }} @if($isVid)
@endif
@endforeach
@php $firstImgId = $allImageIds[0] ?? null; $firstAsset = $galleryAssets[$firstImgId] ?? null; $firstIsVid = $firstAsset && str_contains($firstAsset->file_type, 'video'); @endphp @php $placeholderImg = asset($assetPath . '/images/image-placeholder.png'); @endphp {{ translate($product->name) }}

{{ $product->getTranslation('name', $langCode) }}

{{-- /d-flex wrapper --}}
{{-- /justify-content-between --}} @if ($product->is_bundle && !empty($bundleItems))
{{ webTrans('bundle_products', 'product_details', 'Bundle Products') }} {{ webTrans('view_bundle_products', 'product_details', 'View products in the bundle') }}
@endif @php $pc = optional( $product->productCountry instanceof \Illuminate\Support\Collection ? $product->productCountry->first() : $product->productCountry, ); $variation = optional( $pc->productVariations instanceof \Illuminate\Support\Collection ? $pc->productVariations->first() : null, ); $priceFull = $variation->mrp_price ?? ($pc->mrp_price ?? null); $priceOffer = $variation->offer_price ?? ($pc->offer_price ?? null); $discount = $priceFull && $priceOffer && $priceFull > 0 ? round((($priceFull - $priceOffer) / $priceFull) * 100) : null; $rating = $product->reviews_avg_rating ?? 0; @endphp
@for ($i = 1; $i <= 5; $i++) @if ($i <=round($rating)) @else @endif @endfor
@if($rating > 0) {{ number_format($rating, 1) }} @endif @if($hasOrdered || $product->reviews_count > 0) {{ webTrans('view_all_reviews', 'product_details') }} ({{ $product->reviews_count ?? 0 }}) @endif
@if ($product->is_bundle) {{ ($pc->stock ?? 0) == 1 ? webTrans('in_stock','product_details') : webTrans('out_of_stock','product_details') }} @else {{ webTrans('stock', 'product_details') }} {{ ($pc->number_of_stock ?? 0) > 0 ? '(' . ($pc->number_of_stock ?? 0) . ')' : webTrans('out_of_stock','product_details') }} @endif @auth('web') {{ webTrans('ask_about__this_product', 'product_details') }} @else {{ webTrans('ask_about__this_product', 'product_details') }} @endauth
@if ($priceFull && $priceOffer && $priceFull > $priceOffer)

{{ webFormatPriceWithSymbol($priceOffer, $currentCountry) }} @if ($product->unit) /{{ $product->unit }} @endif

{{ webFormatPriceWithSymbol($priceFull, $currentCountry) }} @elseif($priceFull)

{{ webFormatPriceWithSymbol($priceFull, $currentCountry) }} @if ($product->unit) /{{ $product->unit }} @endif

@elseif($priceOffer)

{{ webFormatPriceWithSymbol($priceOffer, $currentCountry) }} @if ($product->unit) /{{ $product->unit }} @endif

@endif @if ($discount) {{ $discount }}% {{webTrans('off', 'product_details')}} @endif
@if ($pc->getKey() && $pc->hasActiveTax())

{{ webTrans('inclusive_of_all_taxes', 'product_details') }}

@endif @if ($pc && $pc->size_chart_upload_id) {{ webTrans('size_chart', 'product_details') }} @endif
@if ($pc && $pc->is_variant && isset($groupedAttributes)) @php $colorAttr = null; $sizeAttr = null; $otherAttrs = []; foreach ($groupedAttributes as $attr) { $name = strtolower($attr['name']); if (in_array($name, ['colour', 'color', 'لون'])) { $colorAttr = $attr; } elseif (in_array($name, ['size', 'مقas', 'مقاس'])) { $sizeAttr = $attr; } else { $otherAttrs[] = $attr; } } @endphp @if($colorAttr || $sizeAttr)
@if($colorAttr)

{{ $colorAttr['name'] }}

@foreach ($colorAttr['values'] as $val)
@endforeach
@endif @if($sizeAttr)

{{ $sizeAttr['name'] }}

@foreach ($sizeAttr['values'] as $val)
@endforeach
@endif
@endif {{-- Handle any other attributes if they exist --}} @if(!empty($otherAttrs))
@foreach ($otherAttrs as $attr)

{{ $attr['name'] }}

@foreach ($attr['values'] as $val)
@endforeach
@endforeach
@endif @endif @php $showStockAlert = false; $currentStock = (int)($pc->number_of_stock ?? 0); $alertStock = (int)($pc->stock_alert_qty ?? 0); if ($product->is_bundle) { $showStockAlert = ($isBundleLowStock ?? false) && $currentStock > 0; } elseif (!$pc->is_variant) { $showStockAlert = $currentStock <= $alertStock && $currentStock > 0; } @endphp
@if($product->is_bundle) {{ webTrans('hurry_up_limited_quantity_left', 'product_details')}} @else {{ webTrans('hurry_up_few_stock_left', 'product_details') }} @endif

{{ webTrans('quantity', 'product_details') }}

@php $minQty = $pc->min_qty ?? 1; if ($product->is_bundle) { $maxQty = $pc->max_qty > 0 ? $pc->max_qty : 9999; } else { $maxQty = $pc->max_qty > 0 ? min($pc->max_qty, $pc->number_of_stock ?? 0) : $pc->number_of_stock ?? 0; } @endphp
Delivery Box

{{ webTrans('your_product_will_arrive_within', 'product_details') }} {{ $pc->delivery_days ?? 10 }} {{ webTrans('business_days', 'product_details') }}

{{ webTrans('estimated_delivery_before', 'product_details') }} : {{ \Carbon\Carbon::now()->addDays($pc->delivery_days ?? 10)->format('d-M') }}

Offer
@if ($currentCountry && $currentCountry->free_order_threshold_value > 0)

{{ webTrans('free_delivery_offer', 'product_details') }}

{{ webTrans('free_delivery_above', 'product_details') }} {{ webFormatPriceWithSymbol($currentCountry->free_order_delivery_value ?? 0, $currentCountry) }}

@else

{{ webTrans('no_active_offers', 'product_details') }}

{{ webTrans('check_back_later_for_offers', 'product_details') }}

@endif
100% authentic

{{ webTrans('authentic_100', 'product_details') }}

Deliver within {{ $pc->delivery_days ?? 10 }} days

{{ webTrans('deliver_within', 'product_details', 'Deliver within') }} {{ $pc->delivery_days ?? 10 }} {{ webTrans('days', 'product_details', 'days') }}

Easy return policy

{{ webTrans('easy_return_policy', 'product_details') }}

@if ($product->description && !empty(trim(strip_tags($product->getTranslation('description', $langCode)))))

{{ webTrans('description', 'product_details') }}

{!! $product->getTranslation('description', $langCode) !!}
@endif
@if (isset($relatedProducts) && $relatedProducts->count() > 0) @endif @include('frontend::home.modals._bundle_modal') @include('frontend::home.modals.review_rating') @if ($pc && $pc->size_chart_upload_id) @endif @include('frontend::home.scripts.product_detail_scripts') @endsection