@php $isEbay = $this->isMarketplace(); $platformLabel = $this->platformLabel(); @endphp @if ($isEbay) {{-- ══ eBay ORDER SYNC ══════════════════════════════════════════════════ --}}
@php $channel = $this->getRecord(); $recentSyncs = $this->getMarketplaceRecentSyncs(); $shopifyOptions = $this->getShopifyChannels(); $cursor = $this->cursorValue(); $pagedOrders = $this->pagedOrders; $totalPages = $this->totalPages; $totalFiltered = $this->totalFiltered; $stats = $this->stats; @endphp {{-- Settings card --}}
{{-- Header row --}}
Order Sync — {{ $platformLabel }}
@if ($cursor) Cursor: {{ \Carbon\Carbon::parse($cursor)->format('d M Y H:i') }} ({{ \Carbon\Carbon::parse($cursor)->diffForHumans() }}) @else Cursor not set — first sync fetches the last 24 hours @endif
Saved destination: {{ $this->savedDestinationLabel() }}
@if ($this->canSyncNow()) @endif

{{-- Settings form --}}
@if ($this->marketplaceDestination === 'shopify')
@endif
{{-- ── Stat cards ──────────────────────────────────────────────────── --}}
Total Orders
{{ $stats['total'] }}
Paid
{{ $stats['paid'] }}
Unpaid / Pending
{{ $stats['unpaid'] }}
Unlinked Lines
{{ $stats['unlinked'] }}
@if ($stats['unlinked'] > 0) @endif
{{-- ── Orders table ─────────────────────────────────────────────────── --}}
Imported Orders @if($stats['total'] > 0) ({{ $stats['total'] }}) @endif
@if($stats['total'] === 0)

No orders imported yet

Set a date and click Sync Now to pull orders from {{ $platformLabel }}.

@elseif($pagedOrders->isEmpty())

No results for "{{ $orderSearch }}"

@else
@foreach($pagedOrders as $order) @php $isCancelled = $order->status?->value === 'cancelled'; $payStatus = $order->payment_status?->value ?? 'unpaid'; $pillClass = match($payStatus) { 'paid' => 'pill-paid', 'authorized' => 'pill-authorized', default => 'pill-unpaid', }; $payLabel = match($payStatus) { 'paid' => 'Paid', 'authorized' => 'Authorized', default => 'Unpaid', }; $hasUnlinked = ! $isCancelled && $order->orderLines->contains(fn ($l) => $l->product_id === null); @endphp @endforeach
Order {{ $platformLabel }} Order ID Customer Date Payment Lines Subtotal Discount Tax Delivery Total
{{ $order->name }} {{ $order->external_channel_reference ?? $order->external_id ?? '—' }} @if($order->partner) {{ $order->partner->name }} @if($order->partner->email)
{{ $order->partner->email }} @endif @else — @endif
{{ $order->created_at?->format('d M Y') }}
{{ $order->created_at?->format('H:i') }}
@if($isCancelled) Void @else {{ $payLabel }} @if($hasUnlinked)
⚠ Unlinked @endif @endif
@foreach($order->orderLines as $line) @php $unlinked = $line->product_id === null; @endphp
{{ $line->name }} @if($unlinked)[no mapping]@endif ×{{ (int) $line->quantity }} £{{ number_format((float) $line->line_total, 2) }}
@endforeach
£{{ number_format((float) $order->subtotal, 2) }} {{ (float) $order->discount_amount > 0 ? '-£' . number_format((float) $order->discount_amount, 2) : '—' }} £{{ number_format((float) $order->tax_amount, 2) }} £{{ number_format((float) $order->delivery_cost, 2) }} £{{ number_format((float) $order->total_amount, 2) }}
{{-- ── Pagination ──────────────────────────────────────── --}} @if($totalPages > 1 || $totalFiltered > $perPage)
Showing {{ (($page - 1) * $perPage) + 1 }}–{{ min($page * $perPage, $totalFiltered) }} of {{ $totalFiltered }} orders @if($orderSearch !== '') · filtered @endif
Page {{ $page }} of {{ $totalPages }}
@endif @endif
{{-- Recent syncs table --}}
Recent syncs
@if ($recentSyncs->isEmpty())
No sync runs yet — click Sync Now or wait for the scheduler.
@else
@foreach ($recentSyncs as $sync) @php $duration = null; if ($sync->started_at && $sync->finished_at) { $secs = \Carbon\Carbon::parse($sync->started_at)->diffInSeconds(\Carbon\Carbon::parse($sync->finished_at)); $duration = $secs < 60 ? "{$secs}s" : round($secs / 60, 1).'m'; } @endphp @endforeach
Started Duration Status Imported Skip: unpaid Skip: duplicate Failed Destination Message
{{ $sync->started_at ? \Carbon\Carbon::parse($sync->started_at)->diffForHumans() : '—' }} {{ $duration ?? '…' }} @if ($sync->status === 'ok' && ($sync->orders_failed ?? 0) > 0) Failed orders @elseif ($sync->status === 'ok') OK @elseif ($sync->status === 'error') Error @else Running @endif {{ $sync->orders_imported }} {{ $sync->skipped_not_paid ?? $sync->orders_skipped }} {{ $sync->skipped_duplicate ?? 0 }} {{ $sync->orders_failed }} {{ $this->syncDestinationLabel($sync) }} {{ \Illuminate\Support\Str::limit(trim(($sync->error_message ? 'ERROR: '.$sync->error_message." " : '').($sync->message ?? '')), 600) }}
@endif
@else {{-- ══ SHOPIFY ORDER SYNC (existing content) ═══════════════════════════ --}} @php $syncing = $this->isSyncing(); $shouldPoll = $this->shouldPoll(); $lastSynced = $this->lastSyncedAt(); $lastResult = $this->lastResult(); $pagedOrders = $this->pagedOrders; $totalPages = $this->totalPages; $stats = $this->stats; $totalFiltered = $this->totalFiltered; $syncErrors = $this->syncErrors(); $fatalError = $this->fatalError(); @endphp {{-- Always-on background poll: fast while syncing/just triggered, slow otherwise --}} @if($shouldPoll)
@else
@endif {{-- ── Controls bar ──────────────────────────────────────────────── --}}
Order Sync — Shopify
{{-- Warehouse selector --}}
@if($syncing) Syncing… @else Import Orders @endif Starting… Reset Cursor
@if($syncing)
Importing orders from Shopify…
@elseif($lastSynced)
Last synced {{ $lastSynced }} @if($lastResult)  ·  ✓ {{ $lastResult['imported'] }} imported @if($lastResult['skipped'] > 0){{ $lastResult['skipped'] }} skipped@endif @if($lastResult['errors'] > 0)⚠ {{ $lastResult['errors'] }} error(s) — see below@endif @endif
@elseif($fatalError || !empty($syncErrors))
Sync completed with errors — see below
@else
Never synced — click Import Orders to start
@endif
{{-- ── Stat cards ──────────────────────────────────────────────────── --}}
Total Orders
{{ $stats['total'] }}
Paid
{{ $stats['paid'] }}
Unpaid / Pending
{{ $stats['unpaid'] }}
Unlinked Lines
{{ $stats['unlinked'] }}
{{-- ── Fatal error banner ──────────────────────────────────────────── --}} @if($fatalError)
Sync failed — fatal error {{ \Carbon\Carbon::parse($fatalError['at'])->diffForHumans() }}

{{ $fatalError['message'] }}

@if(!empty($fatalError['trace']))
Show stack trace
{{ $fatalError['trace'] }}
@endif
@endif {{-- ── Per-order error list ─────────────────────────────────────────── --}} @if(!empty($syncErrors))
{{ count($syncErrors) }} order(s) failed to import
@foreach($syncErrors as $i => $err)
{{ $err['ref'] ?: $err['shopify_id'] }} {{ $err['message'] }} {{ \Carbon\Carbon::parse($err['at'])->diffForHumans() }}
@if(!empty($err['trace']))
Show stack trace
{{ $err['trace'] }}
@endif
@endforeach
@endif {{-- ── Unlinked lines warning ───────────────────────────────────────── --}} @if($stats['unlinked'] > 0)
{{ $stats['unlinked'] }} order line(s) have no SKU mapping. Go to SKU Mappings to link Shopify products to Cydekick products. These lines are imported but not linked to inventory.
@endif {{-- ── Orders table ─────────────────────────────────────────────────── --}}
@if($stats['total'] === 0)

No orders imported yet

Click Import Orders to pull orders from Shopify.

@elseif($pagedOrders->isEmpty())

No results for "{{ $orderSearch }}"

@else
@foreach($pagedOrders as $order) @php $isCancelled = $order->status?->value === 'cancelled'; $payStatus = $order->payment_status?->value ?? 'unpaid'; $pillClass = match($payStatus) { 'paid' => 'pill-paid', 'authorized' => 'pill-authorized', default => 'pill-unpaid', }; $payLabel = match($payStatus) { 'paid' => 'Paid', 'authorized' => 'Authorized', default => 'Unpaid', }; $hasUnlinked = ! $isCancelled && $order->orderLines->contains(fn ($l) => $l->product_id === null); @endphp @endforeach
Order Shopify Ref Customer Date Payment Lines Subtotal Discount Tax Delivery Total
{{ $order->name }} {{ $order->external_channel_reference ?? '—' }} @if($order->partner) {{ $order->partner->name }} @if($order->partner->email)
{{ $order->partner->email }} @endif @else — @endif
{{ $order->created_at?->format('d M Y') }}
{{ $order->created_at?->format('H:i') }}
@if($isCancelled) Void @else {{ $payLabel }} @if($payStatus === 'authorized' && $order->authorisation_expires_at)
Exp {{ $order->authorisation_expires_at->format('d M Y') }} @endif @if($hasUnlinked)
⚠ Unlinked @endif @endif
@foreach($order->orderLines as $line) @php $unlinked = $line->product_id === null; @endphp
{{ $line->name }} @if($unlinked)[no mapping]@endif ×{{ (int) $line->quantity }} £{{ number_format((float) $line->line_total, 2) }}
@endforeach
£{{ number_format((float) $order->subtotal, 2) }} {{ (float) $order->discount_amount > 0 ? '-£' . number_format((float) $order->discount_amount, 2) : '—' }} £{{ number_format((float) $order->tax_amount, 2) }} £{{ number_format((float) $order->delivery_cost, 2) }} £{{ number_format((float) $order->total_amount, 2) }}
{{-- ── Pagination ─────────────────────────────────────────── --}} @if($totalPages > 1 || $totalFiltered > $perPage)
Showing {{ (($page - 1) * $perPage) + 1 }}–{{ min($page * $perPage, $totalFiltered) }} of {{ $totalFiltered }} orders @if($orderSearch !== '') · filtered @endif
Page {{ $page }} of {{ $totalPages }}
@endif @endif
{{-- ── Legend ─────────────────────────────────────────────────────── --}} @if($stats['total'] > 0)
Orders are imported once and not duplicated on subsequent syncs. ⚠ Unlinked = no SKU mapping found — line is stored but not linked to inventory. Use Reset Cursor to re-check all Shopify orders (already-imported orders are skipped).
@endif @endif {{-- end isEbay / Shopify branch --}}