@php /* * Use the currency selected in Payment Settings rather than * currency codes stored on older purchase records. */ $displayCurrency = currency_code( $displayCurrency ?? $currency ?? default_currency() ); $product = $sale->product; $order = $sale->order; $productTitle = trim( (string) ( $sale->product_title ?? $product?->details?->first()?->title ?? __('Product #:id', [ 'id' => $sale->product_id, ]) ) ); /* * Prefer the main product image. */ $productImageRecord = $product?->images?->firstWhere( 'is_main', true ) ?? $product?->images?->first(); $productImage = $productImageRecord?->image_small ?? $productImageRecord?->image_default; /* * Support old and new payment-status values. */ $paymentStatus = strtolower( trim( (string) ( $order?->payment_status ?? 'pending_payment' ) ) ); $isPaid = in_array( $paymentStatus, [ 'payment_received', 'paid', 'completed', 'successful', 'success', ], true ); [ $paymentBadge, $paymentIcon, $paymentLabel, ] = match ($paymentStatus) { 'payment_received', 'paid', 'completed', 'successful', 'success' => [ 'bg-success', 'fa-check-circle', __('Paid'), ], 'payment_failed', 'failed' => [ 'bg-danger', 'fa-times-circle', __('Payment Failed'), ], 'refunded' => [ 'bg-info text-dark', 'fa-undo', __('Refunded'), ], 'cancelled', 'canceled' => [ 'bg-secondary', 'fa-ban', __('Cancelled'), ], default => [ 'bg-warning text-dark', 'fa-clock', __('Pending Payment'), ], }; $digitalFiles = collect( $product?->digitalFiles ?? [] ); $hasFiles = $digitalFiles->isNotEmpty(); $externalDownloadLink = trim( (string) ( $product?->digital_file_download_link ?? '' ) ); $hasExternalLink = $externalDownloadLink !== ''; $hasLicenseKey = filled($sale->license_key); $purchasePrice = max( 0, (float) ( $sale->price ?? $sale->product_total_price ?? $sale->total_price ?? 0 ) ); /* * Safely parse the purchase date because it may be returned * as a Carbon object or a database string. */ $purchaseDate = null; $rawPurchaseDate = $sale->purchase_date ?? $sale->created_at; if (filled($rawPurchaseDate)) { try { $purchaseDate = \Illuminate\Support\Carbon::parse( $rawPurchaseDate ); } catch (\Throwable) { $purchaseDate = null; } } $orderNumber = $order ? ( filled($order->order_number) ? $order->order_number : $order->id ) : null; $orderUrl = null; if ( $order && \Illuminate\Support\Facades\Route::has( 'account.orders.show' ) ) { try { $orderUrl = route( 'account.orders.show', $order ); } catch (\Throwable) { $orderUrl = null; } } $licenseUrl = null; if ( ($hasLicenseKey || $order) && \Illuminate\Support\Facades\Route::has( 'account.downloads.license' ) ) { try { $licenseUrl = route( 'account.downloads.license', $sale ); } catch (\Throwable) { $licenseUrl = null; } } /* * The main downloads page provides the downloadFirstFile() * and downloadSpecificFile() JavaScript functions. */ $canDownload = $isPaid && ($hasFiles || $hasExternalLink); @endphp
{{-- Product Image --}}
@if(filled($productImage)) {{ $productTitle }} @else
@endif {{-- Payment Status --}} {{ $paymentLabel }} {{-- License Status --}} @if($hasLicenseKey) {{ __('Licensed') }} @endif
{{-- Product Title --}}
{{ $productTitle }}
{{-- Purchase Information --}}
@if($order)
{{ __('Order') }}
@if(filled($orderUrl)) #{{ $orderNumber }} @else #{{ $orderNumber }} @endif
@endif
{{ __('Purchased') }}
@if($purchaseDate) {{ $purchaseDate->format( 'M d, Y' ) }} @else {{ __('N/A') }} @endif
@if($purchaseDate)
{{ $purchaseDate->diffForHumans() }}
@endif
@if(filled($sale->purchase_code))
{{ __('Purchase Code') }}
{{ $sale->purchase_code }}
@endif
{{ __('Price') }}
{{ money( $purchasePrice, $displayCurrency ) }}
{{-- Downloadable Files --}} @if($isPaid && $hasFiles)
{{ trans_choice( 'File (:count)|Files (:count)', $digitalFiles->count(), [ 'count' => number_format( $digitalFiles->count() ), ] ) }} @if($digitalFiles->count() > 1) @endif
@foreach($digitalFiles->take(3) as $file) @php $rawFileName = (string) ( $file->file_name ?? $file->name ?? __('Digital file') ); $fileName = basename( str_replace( '\\', '/', $rawFileName ) ); if ($fileName === '') { $fileName = __('Digital file'); } @endphp
{{ $fileName }}
@endforeach @if($digitalFiles->count() > 3)
{{ trans_choice( '+ :count more file|+ :count more files', $digitalFiles->count() - 3, [ 'count' => number_format( $digitalFiles->count() - 3 ), ] ) }}
@endif
@elseif($isPaid && ! $hasFiles && ! $hasExternalLink)
{{ __( 'No downloadable file is available for this purchase.' ) }}
@elseif(! $isPaid)
{{ __( 'Downloads unlock after payment is confirmed.' ) }}
@endif {{-- External Download Notice --}} @if($isPaid && $hasExternalLink && ! $hasFiles)
{{ __('This purchase uses an external download link.') }}
@endif
{{-- Actions --}}
@once @push('styles') @endpush @endonce @once @push('scripts') @endpush @endonce