@extends('layouts.public') @section('title', $product->name . ' — KalaRhea') @section('breadcrumb') {{ __('Home') }} > {{ __('Shop') }} > {{ $product->name }} @endsection @section('content') @php $wa = \App\Models\Setting::cached('whatsapp_number') ?: '628000000000'; $platformMeta = [ 'shopee' => ['label' => 'Shopee', 'logo' => asset('images/ecommerce/shopee.svg')], 'tokopedia' => ['label' => 'Tokopedia', 'logo' => asset('images/ecommerce/tokopedia.svg')], 'lazada' => ['label' => 'Lazada', 'logo' => asset('images/ecommerce/lazada.svg')], 'blibli' => ['label' => 'Blibli', 'logo' => asset('images/ecommerce/blibli.svg')], ]; $mainImage = $product->primary_image_url; $galleryImages = $product->gallery; $productUrl = route('product.show', ['country' => country()->code(), 'slug' => $product->slug]); $shareText = $product->name . ' — KalaRhea'; @endphp
{{-- GALLERY --}} {{-- INFO --}}

{{ $product->name }}

{{ format_price($product->priceFor()) }}

@if($product->originalPriceFor())

{{ format_price($product->originalPriceFor()) }}

@endif @if($product->description)

{{ $product->description }}

@endif {{-- SIZE & COLOR VARIANTS --}} @php $variantRows = $product->variants; $colorVariants = $variantRows->filter(fn ($v) => $v->color_id !== null); $hasColors = $colorVariants->isNotEmpty(); $colorList = $colorVariants ->sortBy([['color.sort_order', 'asc'], ['color.id', 'asc']]) ->map(fn ($v) => $v->color) ->unique('id') ->values(); $stockMap = []; foreach ($variantRows as $v) { $stockMap[$v->size_id][$v->color_id ?? 0] = (int) $v->stock; } $sizeList = $variantRows ->sortBy('size.sort_order') ->map(fn ($v) => $v->size) ->unique('id') ->values(); $stockFor = function ($sizeId, $colorId) use ($stockMap): int { $map = $stockMap[$sizeId] ?? []; if ($colorId !== null && array_key_exists($colorId, $map)) { return $map[$colorId]; } return $map[0] ?? 0; }; $initialColorId = null; $initialColorIdx = null; if ($hasColors) { foreach ($colorList as $ci => $c) { foreach ($sizeList as $s) { if ($stockFor($s->id, $c->id) > 0) { $initialColorId = $c->id; $initialColorIdx = $ci; break 2; } } } if ($initialColorIdx === null) { $initialColorIdx = 0; $initialColorId = $colorList[0]->id; } } $firstAvailableIdx = null; foreach ($sizeList as $si => $s) { if ($stockFor($s->id, $initialColorId) > 0) { $firstAvailableIdx = $si; break; } } $imageMap = []; foreach ($product->images->whereNotNull('color_id')->sortBy([['is_primary', 'desc'], ['sort_order', 'asc']]) as $img) { if (! isset($imageMap[$img->color_id])) { $imageMap[$img->color_id] = $img->url; } } @endphp @if($variantRows->isNotEmpty()) @if($hasColors)
@foreach($colorList as $ci => $c) @endforeach
@endif
@foreach($sizeList as $i => $s) @php $stock = $stockFor($s->id, $initialColorId); @endphp @endforeach
@endif {{-- QUANTITY --}}
{{-- BUY BUTTON --}}
@php $links = $product->ecommerceLinks; @endphp
{{ __('You can also purchase via:') }}
@foreach($links as $link) @php $meta = $platformMeta[$link->platform] ?? ['label' => ucfirst($link->platform), 'logo' => '']; @endphp {{ $meta['label'] }} @endforeach
{{ __('Share this product') }}
{{-- FEATURES --}}
{{ __('Shipping') }} {{ __('Across Indonesia') }}
{{ __('Authentic Products') }} 100%
{{ __('Customer Service') }} {{ __('Fast Response') }}
{{-- ACCORDION --}}
@php $details = [ ['Material', '100% Linen Premium'], ['Fit', 'Regular Fit'], ['Weight', '250 gram (±)'], ['Color', 'Olive Green'], ]; if ($product->product_details) { $decoded = json_decode($product->product_details, true); if (is_array($decoded)) { if (array_keys($decoded) !== range(0, count($decoded)-1)) { $details = []; foreach ($decoded as $k => $v) { $details[] = [$k, $v]; } } else { $details = $decoded; } } else { // parse plain text lines in pairs $lines = array_filter(array_map('trim', preg_split('/\r\n|\r|\n/', $product->product_details))); if (count($lines) >= 2) { $details = []; for ($i = 0; $i < count($lines); $i += 2) { $key = $lines[$i] ?? ''; $val = $lines[$i+1] ?? ''; if ($key !== '') $details[] = [$key, $val]; } } } } @endphp @foreach($details as $row)
{{ $row[0] ?? '' }} {{ $row[1] ?? '' }}
@endforeach
@php $sizeRows = []; if ($product->size_guide) { $lines = preg_split('/\r\n|\r|\n/', trim($product->size_guide)); foreach ($lines as $line) { $parts = preg_split('/\s{2,}|\t/', $line, 2); if (count($parts) === 2) { $sizeRows[] = [trim($parts[0]), trim($parts[1])]; } else { if (preg_match('/^(\S+)\s+(.*)$/', $line, $m)) { $sizeRows[] = [trim($m[1]), trim($m[2])]; } } } } @endphp @if(count($sizeRows)) @foreach($sizeRows as $row)
{{ $row[0] }}{{ $row[1] }}
@endforeach @else
SChest 96 cm · Length 68 cm
MChest 102 cm · Length 70 cm
LChest 108 cm · Length 72 cm
XLChest 114 cm · Length 74 cm
@endif

{{ $product->care_instructions ?: __('Machine wash cold. Do not bleach. Iron on medium heat. Line dry in the shade — avoid direct sunlight.') }}

{{ $product->shipping_returns ?: __('Shipping across Indonesia via trusted couriers. Estimated 2–5 business days. Returns accepted within 7 days of delivery, in original condition and unused.') }}

@endsection @push('head') @endpush @push('scripts') @endpush