@extends('layouts.content') @section('content')

Detail Pembelian

Lengkapi alamat, gunakan kupon, lalu selesaikan pembayaran.

@if (session('error'))
{{ session('error') }}
@endif @if (isset($successMessage) && $successMessage)
{{ $successMessage }}
@endif
{{-- Bagian Kiri: Alamat & Produk --}}
{{-- 1. Alamat Pengiriman --}}
Alamat Pengiriman
Alamat yang dipilih akan digunakan untuk estimasi dan ongkir.
Tambah Baru
@if($addresses->isEmpty())
Belum ada data alamat pengiriman aktif.
@else @php $defaultAddress = $addresses->firstWhere('address_id', $selectedAddressId) ?? $addresses->first(); @endphp
{{-- Modal Daftar Alamat --}} @endif

{{-- 2. Daftar Produk --}}
Produk Yang Dibeli
@foreach($purchase['items'] as $item)
{{ $item['product_name'] }}
{{ $item['product_name'] }}
Varian: {{ $item['package_label'] }}
Jumlah: {{ $item['quantity'] }}
Rp {{ number_format($item['subtotal'], 0, ',', '.') }}
@endforeach
{{-- Bagian Kanan: Kupon + Summary & Bayar --}}
{{-- 3. Form Penerapan Kupon (Menggunakan GET ke Halaman Ini Sendiri) --}}
Gunakan Kupon Belanja
{{-- Tetap pertahankan data cart_ids di URL saat merefresh halaman verifikasi kupon --}} @if(!empty($purchase['cart_ids'])) @foreach($purchase['cart_ids'] as $id) @endforeach @endif
@if($couponPreview && $couponPreview['valid'] && $couponPreview['discount'] > 0)
✓ Potongan Rp {{ number_format($couponPreview['discount'], 0, ',', '.') }} diterapkan.
@elseif($couponCode && $couponPreview && !$couponPreview['valid'])
⚠ {{ $couponPreview['message'] }}
@endif
{{-- 4. Ringkasan Estimasi & Pembayaran --}}
Ringkasan Pembayaran
Total Produk Rp {{ number_format($summary['subtotal'], 0, ',', '.') }}
Ongkos Kirim ({{ $summary['weight_in_kg'] }} kg) @if(!empty($rateNominalMissing) && $rateNominalMissing) Menunggu konfirmasi @else Rp {{ number_format($summary['shipping_cost'], 0, ',', '.') }} @endif
Diskon Kupon - Rp {{ number_format($summary['coupon_discount'], 0, ',', '.') }}
@if($summary['estimated_days'])
Estimasi Pengiriman: {{ $summary['estimated_days'] }} Hari
@endif
Total Tagihan Rp {{ number_format($summary['total_payment'], 0, ',', '.') }}
{{-- Form POST Transaksi Utama --}}
@csrf {{-- Mengirim array cart_ids ter-encode JSON agar aman dari limitasi URL POST --}} @if(!empty($rateNominalMissing) && $rateNominalMissing)
pending
Tarif Ongkir Belum Tersedia
Admin sedang mengisi nominal tarif untuk wilayah Anda. Halaman akan dapat digunakan setelah admin mengkonfirmasi.
@else @endif
{{-- Script Integration Midtrans --}} @if(config('services.midtrans.is_production', false)) @else @endif @endsection