@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
{{ 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){{ $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.') }}