<?php
$items = cart_items();
$totals = cart_totals($items);
?>
<?php if (!$items): ?>
<?php empty_state('bag', 'Sepetiniz boş', 'Beğendiğiniz ürünleri sepete ekleyerek alışverişe başlayın.', ['Alışverişe başla', url('urunler')]) ?>
<?php else: ?>
<div class="grid gap-10 lg:grid-cols-12 lg:gap-14">
<div class="lg:col-span-7 xl:col-span-8">
<div class="hidden border-b border-zinc-200 pb-3 text-xs font-medium tracking-wide text-zinc-500 uppercase sm:grid sm:grid-cols-12">
<span class="col-span-6">Ürün</span>
<span class="col-span-3 text-center">Adet</span>
<span class="col-span-3 text-right">Toplam</span>
</div>
<ul class="divide-y divide-zinc-100">
<?php foreach ($items as $item): ?>
<li class="grid grid-cols-12 items-center gap-4 py-6">
<div class="col-span-12 flex gap-4 sm:col-span-6">
<a href="<?= product_url($item) ?>" class="h-28 w-24 shrink-0 overflow-hidden rounded-xl bg-zinc-100"><?= product_image($item, 'h-full w-full object-cover', 'text-3xl') ?></a>
<div class="min-w-0">
<a href="<?= product_url($item) ?>" class="font-medium text-ink hover:underline"><?= e($item['name']) ?></a>
<?php if ($item['variant']): ?>
<p class="mt-1 text-sm text-zinc-500"><?= e(product_variant_label($item)) ?></p>
<?php endif ?>
<p class="mt-1 text-sm text-zinc-500"><?= money($item['price']) ?></p>
<form method="post" action="<?= url('sepet-guncelle') ?>" data-ajax class="mt-3">
<?= csrf_field() ?>
<button name="sil" value="<?= e($item['key']) ?>" class="inline-flex items-center gap-1.5 text-[13px] font-medium text-zinc-500 transition hover:text-rose-600"><?= icon('trash', 'size-4') ?>Kaldır</button>
</form>
</div>
</div>
<form method="post" action="<?= url('sepet-guncelle') ?>" data-ajax data-autosubmit class="col-span-6 sm:col-span-3 sm:flex sm:justify-center">
<?= csrf_field() ?>
<?php include PARTS . '/qty-input.php' ?>
</form>
<p class="col-span-6 text-right font-semibold sm:col-span-3"><?= money($item['line_total']) ?></p>
</li>
<?php endforeach ?>
</ul>
</div>
<aside class="lg:col-span-5 xl:col-span-4">
<div class="rounded-3xl bg-zinc-50 p-6 sm:p-8 lg:sticky lg:top-28">
<h2 class="font-display text-xl font-semibold tracking-tight">Sipariş özeti</h2>
<?php if ($totals['coupon']): ?>
<div class="mt-6 flex items-center justify-between rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3">
<span class="flex items-center gap-2 text-sm font-medium text-emerald-800"><?= icon('tag', 'size-4') ?><?= e($totals['coupon']['code']) ?> · <?= e($totals['coupon']['label']) ?></span>
<form method="post" action="<?= url('kupon') ?>" data-ajax>
<?= csrf_field() ?>
<button name="kaldir" value="1" class="text-xs font-semibold text-emerald-800 underline">Kaldır</button>
</form>
</div>
<?php else: ?>
<form method="post" action="<?= url('kupon') ?>" data-ajax class="mt-6 flex gap-2">
<?= csrf_field() ?>
<input name="code" placeholder="Kupon kodu" class="input uppercase placeholder:normal-case" required>
<button class="btn-light shrink-0">Uygula</button>
</form>
<?php endif ?>
<?php include PARTS . '/totals.php' ?>
<?php if ($totals['free_left'] > 0): ?>
<p class="mt-5 flex items-center gap-2 rounded-xl bg-white px-4 py-3 text-[13px] text-zinc-600 ring-1 ring-zinc-200"><?= icon('truck', 'size-4 shrink-0') ?><?= money($totals['free_left']) ?> daha ekleyin, kargo ücretsiz olsun.</p>
<?php endif ?>
<a href="<?= url('odeme') ?>" class="btn-primary mt-6 w-full py-4 text-base">Ödemeye geç <?= icon('arrow', 'size-4', '2') ?></a>
<p class="mt-4 flex items-center justify-center gap-2 text-xs text-zinc-500"><?= icon('lock', 'size-3.5') ?>Güvenli ödeme</p>
</div>
</aside>
</div>
<?php endif ?>
Lisans bilgisi projenin LICENSE dosyasında.