@extends('storefront.layout')
@section('title', ($pageTitle ?? trans_key('storefront.pageTitles.account')).' - '.config('app.name', 'HyperLocal'))
@section('content')
@php
$storefrontQuery = array_filter(['zone' => $selectedZone?->slug, 'service' => $selectedService ?? null]);
$featureLabel = \Illuminate\Support\Str::headline($feature);
@endphp
{{-- ===== BREADCRUMB ===== --}}
{{-- ===== HERO HEADER ===== --}}
{{-- ===== CONTENT ===== --}}
@if($feature === 'wishlist')
Wishlist
{{ $wishlistProducts->count() }} saved products
@if($wishlistProducts->count())
@foreach($wishlistProducts as $product)
@php
$productImages = \App\Support\StorefrontPresenter::productImages($product);
$image = $productImages[0] ?? null;
$defaultVariant = $product->variants->firstWhere('is_default', true) ?: $product->variants->first();
$price = $defaultVariant?->price ?? $product->base_price;
$comparePrice = $defaultVariant?->compare_price ?? $product->compare_price;
$hasDiscount = $comparePrice && (float) $comparePrice > (float) $price;
$discountPercent = $hasDiscount ? (int) round((((float) $comparePrice - (float) $price) / (float) $comparePrice) * 100) : null;
$productUrl = route('storefront.products.show', ['product' => $product] + $storefrontQuery);
$ratingCount = (int) ($product->reviews_count ?? $product->reviews?->count() ?? 0);
$ratingAverage = (float) ($product->reviews_avg_rating ?? 0);
$rating = $ratingAverage > 0 && $ratingCount > 0 ? number_format($ratingAverage, 1) : null;
$hasStock = ! $product->track_inventory || $product->available_quantity === null || (int) $product->available_quantity > 0;
$variantLabel = $defaultVariant?->name ?: ($product->short_description ?: '1 unit');
$cartKey = $product->id . ':' . ($defaultVariant?->id ?? 0);
$cartEntry = $cartLookup[$cartKey] ?? null;
$quantity = (int) data_get($cartEntry, 'quantity', 0);
$cartItemId = data_get($cartEntry, 'cart_item_id');
@endphp
@if($image)
@else
{{ Str::upper(Str::substr($product->name, 0, 1)) }}
{{ $product->category?->name ?? trans_key('storefront.fallbacks.product') }}
@endif
@if($discountPercent)
{{ $discountPercent }}%OFF
@endif
{{ Str::limit($product->name, 28) }}
{{ $variantLabel }}
@if($rating)
{{ $rating }}
({{ $ratingCount }})
@endif
@endforeach
@else
Your wishlist is empty
Save products from the product page.
Browse products
@endif
@elseif($feature === 'addresses')
Manage delivery location
Choose or update your active delivery location from the home screen.
Manage location
@elseif($feature === 'referral')
Referral rewards
Earn rewards by inviting friends
Rewards earned
{{ \App\Support\StorefrontPresenter::money(data_get($customerMeta, 'referral.earned_amount', 0)) }}
Pending rewards
{{ \App\Support\StorefrontPresenter::money(data_get($customerMeta, 'referral.pending_rewards', 0)) }}
@elseif($feature === 'prescriptions')
Prescriptions
Prescription uploads will appear here when pharmacy ordering needs them.
Browse pharmacy
@else
{{ $featureLabel }}
No saved information is available for this account area yet.
Back to profile
@endif
@endsection