@extends('layouts.app')

@section('content')
<div class="container">
    <h3>Checkout dari Keranjang</h3>

    <table border="1" cellpadding="8" cellspacing="0">
        <tr>
            <th>Produk</th>
            <th>Qty</th>
            <th>Harga</th>
            <th>Subtotal</th>
        </tr>

        @php $total = 0; @endphp

        @foreach($cart as $item)
            @php
                $subtotal = $item['harga'] * $item['qty'];
                $total += $subtotal;
            @endphp
            <tr>
                <td>{{ $item['nama'] }}</td>
                <td>{{ $item['qty'] }}</td>
                <td>{{ number_format($item['harga']) }}</td>
                <td>{{ number_format($subtotal) }}</td>
            </tr>
        @endforeach

        <tr>
            <td colspan="3"><strong>Total</strong></td>
            <td><strong>{{ number_format($total) }}</strong></td>
        </tr>
    </table>
</div>
@endsection
