@extends('layouts.app') @section('title', __('My Wishlist')) @php /* * Always display product prices using the currency selected * in Payment Settings. */ $displayCurrency = currency_code( $displayCurrency ?? $currency ?? default_currency() ); @endphp @section('content')
{{-- Page Header --}}

{{ __('My Wishlist') }}

{{ __('Products you have saved for later.') }}

{{ trans_choice( ':count saved product|:count saved products', $items->total(), [ 'count' => number_format( $items->total() ), ] ) }} @if( \Illuminate\Support\Facades\Route::has( 'storefront.products.index' ) ) {{ __('Browse Products') }} @endif
{{-- Flash Messages --}} @if(session('success')) @endif @if(session('error')) @endif @if($items->isNotEmpty())
@foreach($items as $item) @php $product = $item->product; $detail = $product?->details?->first(); $title = trim( (string) ( $detail?->title ?? $product?->slug ?? __('Unavailable product') ) ); $description = \Illuminate\Support\Str::limit( strip_tags( (string) ( $detail?->short_description ?? $detail?->description ?? '' ) ), 110 ); /* * Prefer the main image before falling back * to the first available image. */ $image = $product?->images?->firstWhere( 'is_main', true ) ?? $product?->images?->first(); $imagePath = $image?->image_small ?? $image?->image_big ?? $image?->image_default; $regularPrice = max( 0, (float) ($product?->price ?? 0) ); $discountedPrice = max( 0, (float) ( $product?->price_discounted ?? 0 ) ); $hasDiscount = $discountedPrice > 0 && $discountedPrice < $regularPrice; $sellingPrice = $hasDiscount ? $discountedPrice : $regularPrice; $isDeleted = (bool) ( $product?->is_deleted ?? false ); $isDraft = (bool) ( $product?->is_draft ?? false ); $isPublished = $product !== null && (int) ($product->status ?? 0) === 1 && (bool) ( $product->visibility ?? true ) && (bool) ( $product->is_active ?? true ) && ! $isDeleted && ! $isDraft; $isOutOfStock = $product !== null && $product->product_type === 'physical' && (int) ($product->stock ?? 0) < 1; $isAvailable = $isPublished && ! $isOutOfStock; $rating = max( 0, min( 5, (float) ($product?->rating ?? 0) ) ); $reviewsCount = max( 0, (int) ( $product?->reviews_count ?? 0 ) ); $discountPercentage = ( $hasDiscount && $regularPrice > 0 ) ? min( 100, max( 0, (int) round( ( ( $regularPrice - $discountedPrice ) / $regularPrice ) * 100 ) ) ) : 0; $seller = $product?->seller; $sellerName = trim( (string) ( $seller?->username ?? trim( (string) ( $seller?->first_name ?? '' ) . ' ' . (string) ( $seller?->last_name ?? '' ) ) ) ); if ($sellerName === '') { $sellerName = __('Unknown Seller'); } $productUrl = null; if ( $product && \Illuminate\Support\Facades\Route::has( 'storefront.products.show' ) ) { try { $productUrl = route( 'storefront.products.show', $product ); } catch (\Throwable) { $productUrl = null; } } $sellerUrl = null; if ( $seller && filled($seller->slug) && \Illuminate\Support\Facades\Route::has( 'sellers.show' ) ) { try { $sellerUrl = route( 'sellers.show', [ 'seller' => $seller->slug, ] ); } catch (\Throwable) { $sellerUrl = null; } } $contactUrl = null; if ( $product && $seller && (int) $product->user_id !== (int) auth()->id() && \Illuminate\Support\Facades\Route::has( 'account.messages.create' ) ) { try { $contactUrl = route( 'account.messages.create', [ 'product' => $product->id, ] ); } catch (\Throwable) { $contactUrl = null; } } $cartRouteExists = \Illuminate\Support\Facades\Route::has( 'storefront.cart.items.store' ); $wishlistRouteExists = $product && \Illuminate\Support\Facades\Route::has( 'account.wishlist.toggle' ); @endphp
{{-- Product Image --}}
@if($product && filled($imagePath)) {{ $title }} @else
@endif {{-- Availability --}}
@if(! $product || ! $isPublished) {{ __('Unavailable') }} @elseif($isOutOfStock) {{ __('Out of Stock') }} @elseif( $product->product_type === 'digital' ) {{ __('Digital') }} @else {{ __('In Stock') }} @endif
@if($discountPercentage > 0)
-{{ $discountPercentage }}%
@endif
{{-- Seller --}} @if($seller)
@if(filled($sellerUrl)) {{ $sellerName }} @else {{ $sellerName }} @endif
@endif {{-- Product Title --}}

@if( $isPublished && filled($productUrl) ) {{ $title }} @else {{ $title }} @endif

{{-- Description --}} @if($description !== '')

{{ $description }}

@endif {{-- Rating --}}
@for($star = 1; $star <= 5; $star++) @endfor
{{ number_format($rating, 1) }} ({{ number_format( $reviewsCount ) }})
{{-- Price --}} @if($product)
{{ money( $sellingPrice, $displayCurrency ) }} @if($hasDiscount) {{ money( $regularPrice, $displayCurrency ) }} @endif
@endif {{-- Actions --}}
@if($isPublished)
@if(filled($productUrl)) {{ __('View Product') }} @endif @if( $isAvailable && $cartRouteExists )
@csrf
@endif @if(filled($contactUrl)) {{ __('Contact Seller') }} @endif
@else
{{ __( 'This product is no longer available.' ) }}
@endif {{-- Remove from Wishlist --}} @if($wishlistRouteExists)
@csrf
@elseif(! $product)
{{ __( 'The original product record has been removed.' ) }}
@endif
@if(filled($item->id)) @endif
@endforeach
{{-- Pagination --}} @if($items->hasPages())
{{ $items ->withQueryString() ->links('pagination::bootstrap-5') }}
@endif @else {{-- Empty Wishlist --}}

{{ __('Your wishlist is empty') }}

{{ __( 'Save products you are interested in and return to them whenever you are ready to make a purchase.' ) }}

@if( \Illuminate\Support\Facades\Route::has( 'storefront.products.index' ) ) {{ __('Explore Products') }} @endif
@endif
@endsection @once @push('styles') @endpush @endonce @once @push('scripts') @endpush @endonce