209 lines
8.4 KiB
PHP
209 lines
8.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
$pageTitle = $title ?? 'Checkout';
|
|
$items = is_array($items ?? null) ? $items : [];
|
|
$total = (float)($total ?? 0);
|
|
$subtotal = (float)($subtotal ?? $total);
|
|
$discountAmount = (float)($discount_amount ?? 0);
|
|
$discountCode = (string)($discount_code ?? '');
|
|
$currency = (string)($currency ?? 'GBP');
|
|
$success = (string)($success ?? '');
|
|
$orderNo = (string)($order_no ?? '');
|
|
$error = (string)($error ?? '');
|
|
$downloadLinks = is_array($download_links ?? null) ? $download_links : [];
|
|
$downloadNotice = (string)($download_notice ?? '');
|
|
$downloadLimit = (int)($download_limit ?? 5);
|
|
$downloadExpiryDays = (int)($download_expiry_days ?? 30);
|
|
ob_start();
|
|
?>
|
|
<section class="card checkout-wrap">
|
|
<div class="badge">Store</div>
|
|
<h1 style="margin:0; font-size:32px;">Checkout</h1>
|
|
<?php if ($success !== ''): ?>
|
|
<div style="padding:14px; border-radius:12px; border:1px solid rgba(34,242,165,.4); background:rgba(34,242,165,.12);">
|
|
<div style="font-weight:700;">Order complete</div>
|
|
<?php if ($orderNo !== ''): ?>
|
|
<div style="margin-top:4px; color:var(--muted);">Order: <?= htmlspecialchars($orderNo, ENT_QUOTES, 'UTF-8') ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="checkout-panel">
|
|
<div class="badge" style="font-size:9px;">Your Downloads</div>
|
|
<?php if ($downloadLinks): ?>
|
|
<div style="display:grid; gap:10px; margin-top:10px;">
|
|
<?php foreach ($downloadLinks as $link): ?>
|
|
<?php
|
|
$label = trim((string)($link['label'] ?? 'Download'));
|
|
$url = trim((string)($link['url'] ?? ''));
|
|
if ($url === '') {
|
|
continue;
|
|
}
|
|
?>
|
|
<a href="<?= htmlspecialchars($url, ENT_QUOTES, 'UTF-8') ?>" class="checkout-download-link">
|
|
<span><?= htmlspecialchars($label !== '' ? $label : 'Download', ENT_QUOTES, 'UTF-8') ?></span>
|
|
<span class="checkout-download-link-arrow">Download</span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<p style="margin:10px 0 0; color:var(--muted); font-size:13px;">
|
|
<?= htmlspecialchars($downloadNotice !== '' ? $downloadNotice : 'No downloads available for this order yet.', ENT_QUOTES, 'UTF-8') ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($error !== ''): ?>
|
|
<div style="padding:14px; border-radius:12px; border:1px solid rgba(243,176,176,.45); background:rgba(243,176,176,.12); color:#ffd6d6;">
|
|
<?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!$items): ?>
|
|
<div style="padding:14px; border-radius:12px; border:1px solid rgba(255,255,255,.1); background:rgba(0,0,0,.2); color:var(--muted);">
|
|
Your cart is empty.
|
|
</div>
|
|
<div><a href="/releases" class="btn">Browse releases</a></div>
|
|
<?php else: ?>
|
|
<div class="checkout-grid">
|
|
<div class="checkout-panel">
|
|
<div class="badge" style="font-size:9px;">Order Summary</div>
|
|
<div style="display:grid; gap:10px; margin-top:10px;">
|
|
<?php foreach ($items as $item): ?>
|
|
<?php
|
|
$title = (string)($item['title'] ?? 'Item');
|
|
$qty = max(1, (int)($item['qty'] ?? 1));
|
|
$price = (float)($item['price'] ?? 0);
|
|
$lineCurrency = (string)($item['currency'] ?? $currency);
|
|
?>
|
|
<div class="checkout-line">
|
|
<div class="checkout-line-title"><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ?></div>
|
|
<div class="checkout-line-meta"><?= htmlspecialchars($lineCurrency, ENT_QUOTES, 'UTF-8') ?> <?= number_format($price, 2) ?> x <?= $qty ?></div>
|
|
<div class="checkout-line-total"><?= htmlspecialchars($lineCurrency, ENT_QUOTES, 'UTF-8') ?> <?= number_format($price * $qty, 2) ?></div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="checkout-total">
|
|
<span>Subtotal</span>
|
|
<strong><?= htmlspecialchars($currency, ENT_QUOTES, 'UTF-8') ?> <?= number_format($subtotal, 2) ?></strong>
|
|
</div>
|
|
<?php if ($discountAmount > 0): ?>
|
|
<div class="checkout-total" style="margin-top:8px;">
|
|
<span>Discount (<?= htmlspecialchars($discountCode, ENT_QUOTES, 'UTF-8') ?>)</span>
|
|
<strong style="color:#9be7c6;">-<?= htmlspecialchars($currency, ENT_QUOTES, 'UTF-8') ?> <?= number_format($discountAmount, 2) ?></strong>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="checkout-total" style="margin-top:8px;">
|
|
<span>Order total</span>
|
|
<strong><?= htmlspecialchars($currency, ENT_QUOTES, 'UTF-8') ?> <?= number_format($total, 2) ?></strong>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="checkout-panel">
|
|
<div class="badge" style="font-size:9px;">Buyer Details</div>
|
|
<form method="post" action="/checkout/place" style="display:grid; gap:12px; margin-top:10px;">
|
|
<label style="font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.18em;">Email</label>
|
|
<input name="email" type="email" value="" placeholder="you@example.com" class="checkout-input" required>
|
|
|
|
<div class="checkout-terms">
|
|
<div class="badge" style="font-size:9px;">Terms</div>
|
|
<p style="margin:8px 0 0; color:var(--muted); font-size:13px; line-height:1.5;">
|
|
Digital download products are non-refundable once purchased and delivered. Please check your order details before placing the order.
|
|
Files are limited to <?= $downloadLimit ?> downloads and expire after <?= $downloadExpiryDays ?> days.
|
|
</p>
|
|
<label style="margin-top:10px; display:flex; gap:8px; align-items:flex-start; color:#d7def2; font-size:13px;">
|
|
<input type="checkbox" name="accept_terms" value="1" required style="margin-top:2px;">
|
|
<span>I agree to the terms and understand all sales are final.</span>
|
|
</label>
|
|
</div>
|
|
|
|
<button type="submit" class="checkout-place-btn">Place Order</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
<style>
|
|
.checkout-wrap { display:grid; gap:14px; }
|
|
.checkout-grid { display:grid; grid-template-columns: minmax(0,1fr) 420px; gap:14px; }
|
|
.checkout-panel {
|
|
padding:14px;
|
|
border-radius:12px;
|
|
border:1px solid rgba(255,255,255,.1);
|
|
background:rgba(0,0,0,.2);
|
|
}
|
|
.checkout-line {
|
|
display:grid;
|
|
grid-template-columns:minmax(0,1fr) auto;
|
|
gap:8px;
|
|
padding:10px;
|
|
border-radius:10px;
|
|
border:1px solid rgba(255,255,255,.08);
|
|
background:rgba(255,255,255,.03);
|
|
}
|
|
.checkout-line-title { font-weight:600; }
|
|
.checkout-line-meta { color:var(--muted); font-size:12px; margin-top:4px; grid-column:1/2; }
|
|
.checkout-line-total { font-weight:700; grid-column:2/3; grid-row:1/3; align-self:center; }
|
|
.checkout-total {
|
|
margin-top:10px;
|
|
display:flex;
|
|
align-items:center;
|
|
justify-content:space-between;
|
|
padding:12px;
|
|
border-radius:10px;
|
|
border:1px solid rgba(255,255,255,.1);
|
|
background:rgba(255,255,255,.04);
|
|
}
|
|
.checkout-total strong { font-size:22px; }
|
|
.checkout-input {
|
|
height:40px;
|
|
border-radius:10px;
|
|
border:1px solid rgba(255,255,255,.2);
|
|
background:rgba(255,255,255,.05);
|
|
color:#fff;
|
|
padding:0 12px;
|
|
}
|
|
.checkout-terms {
|
|
padding:12px;
|
|
border-radius:10px;
|
|
border:1px solid rgba(255,255,255,.1);
|
|
background:rgba(255,255,255,.03);
|
|
}
|
|
.checkout-place-btn{
|
|
height:40px;
|
|
border-radius:999px;
|
|
border:1px solid rgba(34,242,165,.45);
|
|
background:rgba(34,242,165,.18);
|
|
color:#cbfff1;
|
|
font-weight:700;
|
|
letter-spacing:.1em;
|
|
text-transform:uppercase;
|
|
cursor:pointer;
|
|
}
|
|
.checkout-place-btn:hover { background:rgba(34,242,165,.28); }
|
|
.checkout-download-link {
|
|
display:flex;
|
|
align-items:center;
|
|
justify-content:space-between;
|
|
gap:10px;
|
|
padding:12px;
|
|
border-radius:10px;
|
|
border:1px solid rgba(34,242,165,.35);
|
|
background:rgba(34,242,165,.1);
|
|
color:#d7ffef;
|
|
text-decoration:none;
|
|
font-weight:600;
|
|
}
|
|
.checkout-download-link:hover { background:rgba(34,242,165,.18); }
|
|
.checkout-download-link-arrow {
|
|
font-size:11px;
|
|
text-transform:uppercase;
|
|
letter-spacing:.14em;
|
|
color:#8df7d1;
|
|
}
|
|
@media (max-width: 900px) {
|
|
.checkout-grid { grid-template-columns: 1fr; }
|
|
}
|
|
</style>
|
|
<?php
|
|
$content = ob_get_clean();
|
|
require __DIR__ . '/../../../../views/site/layout.php';
|