@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
{{ $sale->purchase_code }}