Feat: Order Controller updates

This commit is contained in:
2026-09-30 19:50:03 +03:00
parent 92016256ce
commit a7cdfbd1cb
6 changed files with 87 additions and 17 deletions
@@ -35,7 +35,7 @@
<li class="grid grid-cols-2 gap-x-6 gap-y-2 border-b border-black py-5 sm:grid-cols-[1fr_1fr_1.5fr_1fr_auto] sm:items-center">
<span>
<span class="sr-only">{{ __('storefront.orders.date') }}:</span>
{{ $order->placed_at->format('d/m/Y') }}
{{ $order->placed_at->inDisplayTimezone()->format('d/m/Y') }}
</span>
<span class="text-right font-bold sm:text-left">
<span class="sr-only">{{ __('storefront.orders.number') }}:</span>
+63 -8
View File
@@ -30,7 +30,7 @@
<dl class="grid grid-cols-1 gap-6 border-y border-black py-6 sm:grid-cols-2 lg:grid-cols-4">
<div class="flex flex-col gap-1">
<dt class="text-sm text-neutral-500">{{ __('storefront.orders.date') }}</dt>
<dd>{{ $order->placed_at->format('d/m/Y') }}</dd>
<dd>{{ $order->placed_at->inDisplayTimezone()->format('d/m/Y') }}</dd>
</div>
<div class="flex flex-col gap-1">
@@ -51,15 +51,70 @@
<dd>{{ $shippingLine->description }}</dd>
</div>
@endif
@foreach ($shipments as $shipment)
<div class="flex flex-col gap-1">
<dt class="text-sm text-neutral-500">{{ __('storefront.orders.tracking') }}</dt>
<dd class="break-all">{{ $shipment->tracking_reference }}</dd>
</div>
@endforeach
</dl>
{{-- Shipment tracking: the history we sync from the courier. Only
couriers without an integration link out to their own site. --}}
@if ($shipments->isNotEmpty())
<section class="flex flex-col gap-6" aria-labelledby="order-tracking-heading">
<h2 id="order-tracking-heading" class="font-display text-h4 font-extrabold">{{ __('storefront.orders.tracking') }}</h2>
@foreach ($shipments as $shipment)
@php
$history = $shipment->shipmentInfo->sortByDesc('occurred_at');
$latest = $history->first();
@endphp
<div class="flex flex-col gap-5 border-b border-black pb-6">
<dl class="grid grid-cols-1 gap-6 sm:grid-cols-3">
<div class="flex flex-col gap-1">
<dt class="text-sm text-neutral-500">{{ __('storefront.orders.shipment') }}</dt>
<dd>{{ $shipment->carrierLabel() }}</dd>
</div>
<div class="flex flex-col gap-1">
<dt class="text-sm text-neutral-500">{{ __('storefront.orders.voucher_number') }}</dt>
<dd class="break-all">{{ $shipment->tracking_reference }}</dd>
</div>
<div class="flex flex-col gap-1">
<dt class="text-sm text-neutral-500">{{ __('storefront.orders.shipment_status') }}</dt>
<dd class="font-bold">{{ __('storefront.tracking_status.'.($latest?->status->value ?? 'pending')) }}</dd>
</div>
</dl>
@if ($trackingUrl = $shipment->trackingUrl())
<a href="{{ $trackingUrl }}" target="_blank" rel="noopener" class="inline-flex items-center gap-2 self-start text-sm underline hover:no-underline">
{{ __('storefront.orders.track_on_carrier') }}
</a>
@endif
<div class="flex flex-col gap-3">
<h3 class="text-sm text-neutral-500">{{ __('storefront.orders.tracking_history') }}</h3>
@if ($history->isEmpty())
<p class="text-sm">{{ __('storefront.orders.tracking_empty') }}</p>
@else
<ol class="flex flex-col gap-3">
@foreach ($history as $checkpoint)
<li class="flex flex-col gap-0.5 sm:flex-row sm:gap-6">
<time datetime="{{ $checkpoint->occurred_at->toIso8601String() }}" class="shrink-0 text-sm text-neutral-500 sm:w-36">
{{ $checkpoint->occurred_at->inDisplayTimezone()->format('d/m/Y H:i') }}
</time>
<div class="flex flex-col gap-0.5">
<span>{{ __('storefront.tracking_status.'.$checkpoint->status->value) }}</span>
@if ($details = collect([$checkpoint->location, ($checkpoint->status->value === 'unknown' || $checkpoint->carrier_status === 'manual') ? $checkpoint->message : null])->filter()->implode(' · '))
<span class="text-sm text-neutral-500">{{ $details }}</span>
@endif
</div>
</li>
@endforeach
</ol>
@endif
</div>
</div>
@endforeach
</section>
@endif
{{-- Items + totals --}}
<section class="flex flex-col gap-6" aria-labelledby="order-items-heading">
<h2 id="order-items-heading" class="font-display text-h4 font-extrabold">{{ __('storefront.orders.items') }}</h2>
@@ -1,4 +1,4 @@
{{-- Core passes only the order reference here (and the amount for payment emails). Greek on purpose: sent from the queue in the app default locale. --}}
{{-- Core passes the order, its reference and its active shipments. Greek on purpose: sent from the queue in the app default locale. --}}
@extends('emails.layout')
@section('title', "Η παραγγελία σου στάλθηκε")
@@ -10,12 +10,23 @@
Η παραγγελία σου στάλθηκε
</h1>
<p style="margin:0 0 32px;">Η παραγγελία σου <strong>#{{ $reference }}</strong> είναι καθ’ οδόν. Θα τη λάβεις σύντομα.</p>
<p style="margin:0 0 24px;">Η παραγγελία σου <strong>#{{ $reference }}</strong> είναι καθ’ οδόν. Θα τη λάβεις σύντομα.</p>
@include('emails.partials.button', [
'url' => route('account.orders', ['locale' => 'el']),
'label' => 'Οι παραγγελίες μου',
])
@foreach ($shipments ?? [] as $shipment)
<p style="margin:0 0 8px;">
{{ $shipment->carrierLabel() }} · Αριθμός αποστολής: <strong>{{ $shipment->tracking_reference }}</strong>
@if ($carrierUrl = $shipment->trackingUrl())
· <a href="{{ $carrierUrl }}" style="color:#000000;text-decoration:underline;">Παρακολούθηση στη σελίδα του courier</a>
@endif
</p>
@endforeach
<div style="height:24px;"></div>
{{-- Orders with an account: their order page shows the tracking history we sync from the courier. --}}
@include('emails.partials.button', $order->customer_id
? ['url' => route('account.orders.show', ['locale' => 'el', 'orderId' => $order->id]), 'label' => 'Παρακολούθηση παραγγελίας']
: ['url' => route('account.orders', ['locale' => 'el']), 'label' => 'Οι παραγγελίες μου'])
@endsection
@section('footer')
@@ -46,7 +46,7 @@
<p style="margin:0 0 24px;">
Λάβαμε την παραγγελία σου <strong>#{{ $reference }}</strong>
στις {{ $order->placed_at?->format('d/m/Y') }}.
στις {{ $order->placed_at?->inDisplayTimezone()->format('d/m/Y') }}.
Θα σε ενημερώσουμε με email μόλις σταλεί.
</p>