@php /** @var \App\Models\WaProduct $product */ // Self-derive theme tokens — this partial renders in the child theme's // @section scope and does not inherit the base template's @php locals. $theme = $theme ?? []; $settings = $settings ?? []; $brand = $brand ?? ($theme['brand'] ?? ($settings['brand_color'] ?? '#075E54')); $bg = $bg ?? ($theme['bg'] ?? '#FBFAF6'); $surface = $surface ?? ($theme['surface'] ?? '#FFFFFF'); $border = $border ?? ($theme['border'] ?? '#E5DFD0'); $shopName = $shopName ?? ($workspace?->name ?: 'Store'); $onSale = $product->compare_price_minor && $product->compare_price_minor > $product->price_minor; $savings = $onSale ? $product->compare_price_minor - $product->price_minor : 0; $images = collect([$product->image_url]) ->concat(is_array($product->gallery_json) ? $product->gallery_json : []) ->filter() ->unique() ->values(); $sfFallback = ''; // body_html is stored verbatim (no sanitisation on save/import) and is // rendered raw below on this PUBLIC, same-origin checkout surface — an // unsanitised value is stored XSS. Allow-list sanitise it here at the // render sink so any script/on*/style/iframe payload is stripped while // legitimate rich text survives. require_once is idempotent. require_once app_path('Support/html_sanitize.php'); $bodyHtmlSafe = wadesk_sanitize_html($product->body_html); // ─────────────── Product variants (option combinations) ─────────────── // Additive: when the product has no variants this stays empty and the page // behaves exactly as before (single price + single Add-to-cart). $hasVariants = $product->hasVariants(); $variantList = []; $optionGroups = []; // option name => distinct values, in first-seen order if ($hasVariants) { foreach ($product->variants as $v) { $opts = is_array($v->options_json) ? $v->options_json : []; $normOpts = []; foreach ($opts as $name => $val) { $name = (string) $name; $val = (string) $val; $normOpts[$name] = $val; if (!isset($optionGroups[$name])) $optionGroups[$name] = []; if (!in_array($val, $optionGroups[$name], true)) $optionGroups[$name][] = $val; } $vp = $v->effectivePriceMinor(); $variantList[] = [ 'id' => (int) $v->id, 'options' => $normOpts, 'price' => $vp, 'price_display' => \App\Models\WaProduct::formatCurrency($vp, $product->currency_code), 'stock' => $v->availableQty(), 'label' => $v->label(), 'image' => $v->image_url, 'sku' => $v->sku, ]; } } $variantPrices = array_column($variantList, 'price'); $variantMinDisplay = $variantPrices ? \App\Models\WaProduct::formatCurrency(min($variantPrices), $product->currency_code) : $product->price_display; @endphp

{{ $product->name }}

@if ($hasVariants) {{ __('from') }} {{ $variantMinDisplay }} @else {{ $product->price_display }} @if ($onSale) {{ $product->compare_price_display }} Save {{ (int) round(($savings / $product->compare_price_minor) * 100) }}% @endif @endif
@if ($product->in_stock) @if ($product->stock_qty !== null && $product->stock_qty <= 10) Only {{ $product->stock_qty }} left @else In stock · ready to ship @endif @else {{ __('Sold out') }} @endif
@if ($product->description)

{{ $product->description }}

@endif @if ($hasVariants)
@foreach ($optionGroups as $name => $values)
{{ $name }}
@foreach ($values as $val) @endforeach
@endforeach
@endif
@if ($waNumber) Ask a question on WhatsApp @endif
@if ($product->sku)
{{ __('SKU') }}
{{ $product->sku }}
@endif @if ($product->category)
{{ __('Category') }}
{{ $product->category }}
@endif @if ($product->weight_grams)
{{ __('Weight') }}
{{ $product->weight_grams }} g
@endif
{{ __('Delivery') }}
2–5 business days
@if (is_array($product->tags_json) && count($product->tags_json))
{{ __('Tags') }}
@foreach ($product->tags_json as $t) {{ $t }} @endforeach
@endif
{!! $bodyHtmlSafe ?: '

' . e($product->description ?: 'No description available yet — message the seller on WhatsApp to learn more.') . '

' !!}
@php $shipFreeMinor = (int) ($sf->shipping_json['free_threshold'] ?? 99900); $shipFreeText = \App\Support\FormatSettings::formatIn($shipFreeMinor / 100, $sf->currency_code ?? 'USD'); @endphp

{{ __('Shipping.') }} Orders are dispatched within 1–2 business days. Delivery times depend on your location — typically 2–5 business days. Free shipping on orders above {{ $shipFreeText }}.

{{ __('Returns.') }} Unused items can be returned within 7 days of delivery. Message us on WhatsApp to start a return — we'll arrange the pickup.

@if (($ratingCount ?? 0) > 0)
{{ $ratingAvg }} {{ str_repeat('★', (int) round($ratingAvg)) }}{{ str_repeat('★', 5 - (int) round($ratingAvg)) }} {{ trans_choice('{1}:count review|[2,*]:count reviews', $ratingCount, ['count' => $ratingCount]) }}
@foreach ($reviews as $rv)
{{ $rv->customer_name ?: __('Anonymous') }} {{ str_repeat('★', $rv->rating) }}{{ str_repeat('★', 5 - $rv->rating) }}
@if ($rv->body)

{{ $rv->body }}

@endif
@endforeach @else

{{ __('No reviews yet — be the first to review this product.') }}

@endif
{{ __('Write a review') }}
@if (isset($related) && $related->count() > 0) @endif