@php use Botble\Base\Facades\BaseHelper; use Botble\Ecommerce\Facades\EcommerceHelper; use Botble\Media\Facades\RvMedia; /** * Mirrors html/home-pet-care.html §7 (lines 2522-2657): `banner-product-single * section-image-zoom` — single product detail panel with NO thumbnail strip, * NO color swatches, NO buy-it-now/wishlist/compare/payment icons. Slim layout: * LEFT single image + image-zoom * RIGHT [PET CARE tag] [name] [stars + reviews + sold-urgency] [price + old + -%] * [description] [Hurry Up countdown] [Sold-It progress bar] * [Size buttons] [Quantity stepper + Add To Cart] * * Shortcode attributes (all optional, with safe fallbacks): * product_id required — fetched via the parent partial * detail_tag section breadcrumb tag (default first category, fallback "Shop") * reviews_count hardcoded badge count (default 0 = hide) * urgency_text "18 sold in last 32 hours" — empty = hide row * countdown_seconds 0 = hide * countdown_label "Hurry Up! Offer ends In:" (\\n preserved) * sold_percent 0-100, 0 = hide * stock_text "Only 24 item(s) left in stock!" * size_options CSV: "Label|price,Label|price,..." (e.g. "25 lbs|39.99,50 Lbs|59.99") * default_size_index 0-based active index (default 0) * show_view_full yes/no link below */ $detailTag = trim((string) ($shortcode->detail_tag ?? '')); if ($detailTag === '' && $product) { $firstCat = $product->categories?->first(); $detailTag = strtoupper((string) ($firstCat?->name ?? __('Shop'))); } $reviewsCount = (int) ($shortcode->reviews_count ?? 0); $urgencyText = trim((string) ($shortcode->urgency_text ?? '')); $countdown = (int) ($shortcode->countdown_seconds ?? 0); $countdownLbl = (string) ($shortcode->countdown_label ?? __('Hurry Up!') . "\n" . __('Offer ends In:')); $soldPercent = max(0, min(100, (int) ($shortcode->sold_percent ?? 0))); $stockText = trim((string) ($shortcode->stock_text ?? '')); $showViewFull = filter_var($shortcode->show_view_full ?? 'no', FILTER_VALIDATE_BOOLEAN); // wrapper_style: appended to `banner-product-single` for demo-specific modifiers. // Demo §6 of home-organic.html (L2342) uses `banner-product-single style-3 section-image-zoom`. $allowedWrapper = ['', 'style-3']; $rawWrapper = $shortcode->wrapper_style ?? ''; $wrapperStyle = in_array($rawWrapper, $allowedWrapper, true) ? $rawWrapper : ''; // container_class: switch the inner `.container` to `container-2` (wider) when the // demo asks for it. Default keeps back-compat (HomePetCare's slim panel uses container). $allowedContainers = ['container', 'container-2', 'container-full']; $rawContainer = $shortcode->container_class ?? 'container'; $containerClass = in_array($rawContainer, $allowedContainers, true) ? $rawContainer : 'container'; // badge_text: small "Best seller" / "Hot deal" pill rendered before the urgency // text (matches demo §6 L2442-2444 `text-sale text-label fw-semibold`). $badgeText = trim((string) ($shortcode->badge_text ?? '')); // show_thumb_slider='yes' — render vertical thumbs synced to a main image swiper // using $product->images (falls back to single main image). Matches demo §6 // L2346-2416. Default 'no' preserves HomePetCare's single-image layout. $showThumbSlider = ($shortcode->show_thumb_slider ?? 'no') === 'yes'; // show_buy_it_now='yes' adds a primary "Buy It Now" button under Add To Cart // (demo §6 L2489-2492). $showBuyItNow = ($shortcode->show_buy_it_now ?? 'no') === 'yes'; // show_action_boxes='yes' renders the wishlist + compare icon boxes alongside // Add To Cart (demo §6 L2478-2487). $showActionBoxes = ($shortcode->show_action_boxes ?? 'no') === 'yes'; // Gallery images for the thumb slider (when enabled). $galleryImages = []; if ($showThumbSlider && $product) { $galleryImages = collect($product->images ?? []) ->filter(fn ($img) => is_string($img) && trim($img) !== '') ->values() ->all(); if (empty($galleryImages) && $product->image) { $galleryImages = [$product->image]; } } // Parse size options CSV. Each entry "Label|price" or just "Label". $sizeOptions = []; $rawSizeOpts = $shortcode->size_options ?? null; if (! empty($rawSizeOpts)) { foreach (explode(',', (string) $rawSizeOpts) as $entry) { $entry = trim($entry); if ($entry === '') continue; [$label, $price] = array_pad(explode('|', $entry, 2), 2, null); $sizeOptions[] = ['label' => trim((string) $label), 'price' => trim((string) $price)]; } } $defaultSizeIdx = max(0, min(count($sizeOptions) - 1, (int) ($shortcode->default_size_index ?? 0))); $isOnSale = $product && $product->front_sale_price !== null && $product->price > 0 && (float) $product->front_sale_price < (float) $product->price; $salePercent = $isOnSale ? (int) round((1 - ((float) $product->front_sale_price / (float) $product->price)) * 100) : 0; $mainImage = $product ? RvMedia::getImageUrl($product->image, 'hero-banner', false, RvMedia::getDefaultImage()) : null; @endphp @if ($product)
$wrapperStyle !== '', 'section-image-zoom'])>
@if ($showThumbSlider && count($galleryImages) > 0) {{-- Vertical thumb slider — mirrors home-organic.html §6 L2346-2416 --}}
@if (count($galleryImages) > 1)
@foreach ($galleryImages as $img)
{!! RvMedia::image($img, $product->name, 'thumb', false, ['loading' => 'lazy', 'width' => 82, 'height' => 110]) !!}
@endforeach
@endif
@else
{{ $product->name }}
@endif
@if ($detailTag !== '')

{{ $detailTag }}

@endif {{ $product->name }}
@if ($reviewsCount > 0)
@for ($i = 0; $i < 5; $i++) @endfor
({{ $reviewsCount }} {{ __('reviews') }})
@endif @if ($badgeText !== '') {{ $badgeText }} @endif @if ($urgencyText !== '')
{{ $urgencyText }}
@endif

{{ format_price($product->front_sale_price_with_taxes ?? $product->price_with_taxes ?? ($product->front_sale_price ?? $product->price)) }}

@if ($isOnSale)

{{ format_price($product->price_with_taxes ?? $product->price) }}

-{{ $salePercent }}% @endif
@if (! empty($product->description))

{!! BaseHelper::clean($product->description) !!}

@endif
@if ($countdown > 0 || $soldPercent > 0)
@if ($countdown > 0)

{!! nl2br(BaseHelper::clean($countdownLbl)) !!}

@endif @if ($soldPercent > 0)

{{ __('Sold It:') }}

{{ $soldPercent }}% {{ __('Sold') }} @if ($stockText !== '') - {{ $stockText }} @endif

@endif
@endif
@if (! empty($sizeOptions)) @php $activeSize = $sizeOptions[$defaultSizeIdx] ?? $sizeOptions[0]; @endphp
{{ __('Size:') }} {{ $activeSize['label'] }}
@foreach ($sizeOptions as $i => $opt) {{ $opt['label'] }} @endforeach
@endif @if (EcommerceHelper::isCartEnabled())

{{ __('Quantity:') }}

@if ($showBuyItNow) {{ __('Buy It Now') }} @endif
@endif @if ($showViewFull) @endif
@endif