@extends('layouts.app') @section('content')
{{ $product->name }} @if($product->is_top_seller)
TOP SELLER
@endif @if($product->discount_percentage > 0)
DISCOUNT {{ $product->discount_percentage }}%
@endif
@if($product->video)
@endif @if($product->image)
Thumbnail Utama
@endif @foreach($product->images as $img)
Thumbnail Gallery
@endforeach
@foreach($product->categories as $cat) {{ $cat->name }} @endforeach

{{ $product->name }}

{{ number_format($product->manual_rating ?? $product->reviews_avg_rating ?? 0, 1) }}
{{ $product->sold_count }} Terjual
@if($product->discount_percentage > 0)
{{ \App\Models\Setting::get('currency_symbol', 'Rp') }} {{ number_format($product->starting_price, 0, ',', '.') }} -{{ $product->discount_percentage }}%

{{ \App\Models\Setting::get('currency_symbol', 'Rp') }} {{ number_format($product->starting_price * (1 - $product->discount_percentage/100), 0, ',', '.') }}

@else

{{ \App\Models\Setting::get('currency_symbol', 'Rp') }} {{ number_format($product->starting_price, 0, ',', '.') }}

@endif

{{ $product->description }}

@php $variationStructure = []; $allVariations = $product->productVariations; $variationKeys = []; // Keys that determine the variation ID if ($allVariations->count() > 0) { foreach ($allVariations as $variation) { $attributes = $variation->attributes; if (is_string($attributes)) { $attributes = json_decode($attributes, true) ?? []; } foreach ($attributes as $key => $value) { $variationStructure[$key][] = $value; if (!in_array($key, $variationKeys)) { $variationKeys[] = $key; } } } foreach ($variationStructure as $key => $values) { $variationStructure[$key] = array_values(array_unique($values)); } } // Merge Global Variations (stored in variation_options) $globalOptions = $product->variation_options; if (is_string($globalOptions)) { $globalOptions = json_decode($globalOptions, true); } if (is_array($globalOptions)) { // Check if associative array (key => options) $isAssociative = count(array_filter(array_keys($globalOptions), 'is_string')) > 0; if ($isAssociative) { foreach ($globalOptions as $name => $opts) { if (is_array($opts) && count($opts) > 0) { if (!isset($variationStructure[$name])) { $variationStructure[$name] = $opts; } else { $variationStructure[$name] = array_values(array_unique(array_merge($variationStructure[$name], $opts))); } } } } elseif (!empty($product->variation_name)) { // Legacy single variation $legacyName = $product->variation_name; if (!isset($variationStructure[$legacyName])) { $variationStructure[$legacyName] = $globalOptions; } else { $variationStructure[$legacyName] = array_values(array_unique(array_merge($variationStructure[$legacyName], $globalOptions))); } } } @endphp @if(!empty($variationStructure))
@foreach($variationStructure as $groupName => $options)

{{ $groupName }}

@foreach($options as $option) @endforeach
@endforeach
@endif
@if($product->status == 'active') Order/Beli Sekarang
@csrf
@else
Produk ini tidak tersedia.
@endif

Testimoni Member

@forelse($allReviews as $review)
@if($review->profile_photo) {{ $review->user->name }} @else
{{ substr($review->user->name, 0, 1) }}
@endif

{{ $review->user->name }}

@for($i=1; $i<=5; $i++) @endfor
{{ $review->created_at->diffForHumans() }}

{{ $review->comment }}

@if(!empty($review->video_url) || (!empty($review->images) && is_array($review->images)) || $review->image)
@if(!empty($review->video_url)) @php $video_id = ''; $is_youtube = false; if(preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $review->video_url, $match)) { $video_id = $match[1]; $is_youtube = true; } @endphp
video_url')" }}"> @if($is_youtube) Video Review @else @endif
Video
@endif @if(!empty($review->images) && is_array($review->images)) @foreach($review->images as $img)
Review Image
@endforeach @elseif($review->image)
Review Image
@endif
@endif @if($review->reply_comment)
Balasan Admin
@if(isset($globalAdminPhoto) && $globalAdminPhoto) Admin @elseif($review->admin_photo) Admin @else
ADM
@endif
Admin {{ $storeName ?? 'Response' }}

{{ $review->reply_comment }}

@endif
@empty

Belum ada testimoni dari member kami.

@endforelse

Tulis Testimoni

@csrf
@if($relatedProducts->count() > 0)

Produk Sejenis Lainnya

@foreach($relatedProducts as $related)
{{ $related->name }}

{{ $related->name }}

{{ number_format($related->manual_rating ?? $related->reviews_avg_rating ?? 0, 1) }}
|
{{ $related->sold_count ?? 0 }} Terjual

{{ \App\Models\Setting::get('currency_symbol', 'Rp') }} {{ number_format($related->current_price ?? $related->starting_price, 0, ',', '.') }}

Lihat
@endforeach
@endif @endsection