Release v1.5.1
This commit is contained in:
@@ -1,35 +1,51 @@
|
||||
<?php
|
||||
$pageTitle = $title ?? 'Store Settings';
|
||||
$settings = $settings ?? [];
|
||||
<?php
|
||||
use Core\Services\Plugins;
|
||||
|
||||
$pageTitle = $title ?? 'Store Settings';
|
||||
$settings = $settings ?? [];
|
||||
$gateways = is_array($gateways ?? null) ? $gateways : [];
|
||||
$error = (string)($error ?? '');
|
||||
$saved = (string)($saved ?? '');
|
||||
$tab = (string)($tab ?? 'general');
|
||||
$tab = in_array($tab, ['general', 'payments', 'emails', 'discounts', 'sales_chart'], true) ? $tab : 'general';
|
||||
$tab = in_array($tab, ['general', 'payments', 'emails', 'discounts', 'bundles', 'sales_chart'], true) ? $tab : 'general';
|
||||
$paypalTest = (string)($_GET['paypal_test'] ?? '');
|
||||
$privateRootReady = (bool)($private_root_ready ?? false);
|
||||
$discounts = is_array($discounts ?? null) ? $discounts : [];
|
||||
$bundles = is_array($bundles ?? null) ? $bundles : [];
|
||||
$bundleReleaseOptions = is_array($bundle_release_options ?? null) ? $bundle_release_options : [];
|
||||
$chartRows = is_array($chart_rows ?? null) ? $chart_rows : [];
|
||||
$chartLastRebuildAt = (string)($chart_last_rebuild_at ?? '');
|
||||
$chartCronUrl = (string)($chart_cron_url ?? '');
|
||||
$chartCronCmd = (string)($chart_cron_cmd ?? '');
|
||||
ob_start();
|
||||
?>
|
||||
$reportsEnabled = Plugins::isEnabled('advanced-reporting');
|
||||
ob_start();
|
||||
?>
|
||||
<section class="admin-card">
|
||||
<div class="badge">Store</div>
|
||||
<div style="display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px;">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px;">
|
||||
<div>
|
||||
<h1 style="font-size:28px; margin:0;">Store Settings</h1>
|
||||
<p style="color: var(--muted); margin-top:6px;">Configure defaults, payments, and transactional emails.</p>
|
||||
</div>
|
||||
<a href="/admin/store" class="btn outline">Back</a>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:12px;">
|
||||
<a href="/admin/store/settings?tab=general" class="btn <?= $tab === 'general' ? '' : 'outline' ?> small">General</a>
|
||||
<a href="/admin/store" class="btn outline">Back</a>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:12px;">
|
||||
<a href="/admin/store" class="btn outline small">Overview</a>
|
||||
<a href="/admin/store/settings" class="btn small">Settings</a>
|
||||
<a href="/admin/store/orders" class="btn outline small">Orders</a>
|
||||
<a href="/admin/store/customers" class="btn outline small">Customers</a>
|
||||
<?php if ($reportsEnabled): ?>
|
||||
<a href="/admin/store/reports" class="btn outline small">Sales Reports</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:12px;">
|
||||
<a href="/admin/store/settings?tab=general" class="btn <?= $tab === 'general' ? '' : 'outline' ?> small">General</a>
|
||||
<a href="/admin/store/settings?tab=payments" class="btn <?= $tab === 'payments' ? '' : 'outline' ?> small">Payments</a>
|
||||
<a href="/admin/store/settings?tab=emails" class="btn <?= $tab === 'emails' ? '' : 'outline' ?> small">Emails</a>
|
||||
<a href="/admin/store/settings?tab=discounts" class="btn <?= $tab === 'discounts' ? '' : 'outline' ?> small">Discounts</a>
|
||||
<a href="/admin/store/settings?tab=bundles" class="btn <?= $tab === 'bundles' ? '' : 'outline' ?> small">Bundles</a>
|
||||
<a href="/admin/store/settings?tab=sales_chart" class="btn <?= $tab === 'sales_chart' ? '' : 'outline' ?> small">Sales Chart</a>
|
||||
</div>
|
||||
|
||||
@@ -91,10 +107,10 @@ ob_start();
|
||||
<button class="btn" type="submit">Save General Settings</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php elseif ($tab === 'payments'): ?>
|
||||
<form method="post" action="/admin/store/settings" style="margin-top:16px; display:grid; gap:16px;">
|
||||
<input type="hidden" name="tab" value="payments">
|
||||
<div class="admin-card" style="padding:16px;">
|
||||
<?php elseif ($tab === 'payments'): ?>
|
||||
<form method="post" action="/admin/store/settings" style="margin-top:16px; display:grid; gap:16px;">
|
||||
<input type="hidden" name="tab" value="payments">
|
||||
<div class="admin-card" style="padding:16px;">
|
||||
<div class="label" style="margin-bottom:10px;">Payment Mode</div>
|
||||
<input type="hidden" name="store_test_mode" value="0">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.2em;">
|
||||
@@ -103,22 +119,78 @@ ob_start();
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="admin-card" style="padding:16px;">
|
||||
<div class="label" style="margin-bottom:10px;">PayPal</div>
|
||||
<input type="hidden" name="store_paypal_enabled" value="0">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.2em;">
|
||||
<input type="checkbox" name="store_paypal_enabled" value="1" <?= ((string)($settings['store_paypal_enabled'] ?? '0') === '1') ? 'checked' : '' ?>>
|
||||
Enable PayPal
|
||||
</label>
|
||||
<div class="label" style="margin-top:10px;">PayPal Client ID</div>
|
||||
<input class="input" name="store_paypal_client_id" value="<?= htmlspecialchars((string)($settings['store_paypal_client_id'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
|
||||
<div class="label" style="margin-top:10px;">PayPal Secret</div>
|
||||
<input class="input" name="store_paypal_secret" value="<?= htmlspecialchars((string)($settings['store_paypal_secret'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
|
||||
|
||||
<div style="margin-top:12px; display:flex; gap:8px; flex-wrap:wrap;">
|
||||
<button class="btn outline small" type="submit" name="paypal_probe_mode" value="live" formaction="/admin/store/settings/test-paypal" formmethod="post">Test PayPal Live</button>
|
||||
<button class="btn outline small" type="submit" name="paypal_probe_mode" value="sandbox" formaction="/admin/store/settings/test-paypal" formmethod="post">Test PayPal Sandbox</button>
|
||||
<button class="btn" type="submit">Save Payment Settings</button>
|
||||
<div class="admin-card" style="padding:16px;">
|
||||
<div class="label" style="margin-bottom:10px;">PayPal</div>
|
||||
<input type="hidden" name="store_paypal_enabled" value="0">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.2em;">
|
||||
<input type="checkbox" name="store_paypal_enabled" value="1" <?= ((string)($settings['store_paypal_enabled'] ?? '0') === '1') ? 'checked' : '' ?>>
|
||||
Enable PayPal
|
||||
</label>
|
||||
<div class="label" style="margin-top:10px;">PayPal Client ID</div>
|
||||
<input class="input" name="store_paypal_client_id" value="<?= htmlspecialchars((string)($settings['store_paypal_client_id'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
|
||||
<div class="label" style="margin-top:10px;">PayPal Secret</div>
|
||||
<input class="input" name="store_paypal_secret" value="<?= htmlspecialchars((string)($settings['store_paypal_secret'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
|
||||
|
||||
<div style="display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:12px;">
|
||||
<div>
|
||||
<div class="label">Merchant Country</div>
|
||||
<input class="input" name="store_paypal_merchant_country" value="<?= htmlspecialchars((string)($settings['store_paypal_merchant_country'] ?? ''), ENT_QUOTES, 'UTF-8') ?>" placeholder="GB">
|
||||
</div>
|
||||
<div>
|
||||
<div class="label">Card Button Label</div>
|
||||
<input class="input" name="store_paypal_card_branding_text" value="<?= htmlspecialchars((string)($settings['store_paypal_card_branding_text'] ?? 'Pay with card'), ENT_QUOTES, 'UTF-8') ?>" placeholder="Pay with card">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:12px;">
|
||||
<div>
|
||||
<div class="label">Card Checkout Mode</div>
|
||||
<select class="input" name="store_paypal_sdk_mode">
|
||||
<?php $sdkMode = (string)($settings['store_paypal_sdk_mode'] ?? 'embedded_fields'); ?>
|
||||
<option value="embedded_fields" <?= $sdkMode === 'embedded_fields' ? 'selected' : '' ?>>Embedded card fields</option>
|
||||
<option value="paypal_only_fallback" <?= $sdkMode === 'paypal_only_fallback' ? 'selected' : '' ?>>PayPal-only fallback</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="display:flex; align-items:end;">
|
||||
<div style="padding:12px 14px; border:1px solid rgba(255,255,255,.08); border-radius:12px; background:rgba(255,255,255,.03); width:100%;">
|
||||
<input type="hidden" name="store_paypal_cards_enabled" value="0">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.2em;">
|
||||
<input type="checkbox" name="store_paypal_cards_enabled" value="1" <?= ((string)($settings['store_paypal_cards_enabled'] ?? '0') === '1') ? 'checked' : '' ?>>
|
||||
Enable Credit / Debit Card Checkout
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$capabilityStatus = (string)($settings['store_paypal_cards_capability_status'] ?? 'unknown');
|
||||
$capabilityMessage = (string)($settings['store_paypal_cards_capability_message'] ?? 'Run a PayPal credentials test to check card-field support.');
|
||||
$capabilityCheckedAt = (string)($settings['store_paypal_cards_capability_checked_at'] ?? '');
|
||||
$capabilityMode = (string)($settings['store_paypal_cards_capability_mode'] ?? '');
|
||||
$capabilityColor = '#c7cfdf';
|
||||
if ($capabilityStatus === 'available') {
|
||||
$capabilityColor = '#9be7c6';
|
||||
} elseif ($capabilityStatus === 'unavailable') {
|
||||
$capabilityColor = '#f3b0b0';
|
||||
}
|
||||
?>
|
||||
<div style="margin-top:12px; padding:14px; border-radius:12px; border:1px solid rgba(255,255,255,.08); background:rgba(255,255,255,.03); display:grid; gap:6px;">
|
||||
<div class="label" style="font-size:10px;">Card Capability</div>
|
||||
<div style="font-weight:700; color:<?= htmlspecialchars($capabilityColor, ENT_QUOTES, 'UTF-8') ?>; text-transform:uppercase; letter-spacing:.12em;">
|
||||
<?= htmlspecialchars($capabilityStatus !== '' ? $capabilityStatus : 'unknown', ENT_QUOTES, 'UTF-8') ?>
|
||||
</div>
|
||||
<div style="font-size:13px; color:var(--muted);"><?= htmlspecialchars($capabilityMessage, ENT_QUOTES, 'UTF-8') ?></div>
|
||||
<?php if ($capabilityCheckedAt !== ''): ?>
|
||||
<div style="font-size:12px; color:var(--muted);">
|
||||
Last checked: <?= htmlspecialchars($capabilityCheckedAt, ENT_QUOTES, 'UTF-8') ?><?= $capabilityMode !== '' ? ' (' . htmlspecialchars($capabilityMode, ENT_QUOTES, 'UTF-8') . ')' : '' ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div style="margin-top:12px; display:flex; gap:8px; flex-wrap:wrap;">
|
||||
<button class="btn outline small" type="submit" name="paypal_probe_mode" value="live" formaction="/admin/store/settings/test-paypal" formmethod="post">Test PayPal Live</button>
|
||||
<button class="btn outline small" type="submit" name="paypal_probe_mode" value="sandbox" formaction="/admin/store/settings/test-paypal" formmethod="post">Test PayPal Sandbox</button>
|
||||
<button class="btn" type="submit">Save Payment Settings</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -230,6 +302,89 @@ ob_start();
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif ($tab === 'bundles'): ?>
|
||||
<div class="admin-card" style="margin-top:16px; padding:16px;">
|
||||
<div class="label" style="margin-bottom:10px;">Create Bundle</div>
|
||||
<form method="post" action="/admin/store/bundles/create" style="display:grid; gap:12px;">
|
||||
<div style="display:grid; grid-template-columns:1.3fr .8fr .7fr .6fr; gap:10px;">
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Bundle Name</div>
|
||||
<input class="input" name="name" placeholder="Hard Dance Essentials" required>
|
||||
</div>
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Slug (optional)</div>
|
||||
<input class="input" name="slug" placeholder="hard-dance-essentials">
|
||||
</div>
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Bundle Price</div>
|
||||
<input class="input" name="bundle_price" value="9.99" required>
|
||||
</div>
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Currency</div>
|
||||
<input class="input" name="currency" value="<?= htmlspecialchars((string)($settings['store_currency'] ?? 'GBP'), ENT_QUOTES, 'UTF-8') ?>" maxlength="3">
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:grid; grid-template-columns:1fr auto; gap:10px; align-items:end;">
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Button Label (optional)</div>
|
||||
<input class="input" name="purchase_label" placeholder="Buy Discography">
|
||||
</div>
|
||||
<label style="display:flex; align-items:center; gap:6px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.16em; padding-bottom:6px;">
|
||||
<input type="checkbox" name="is_enabled" value="1" checked> Active
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<div class="label" style="font-size:10px;">Releases in Bundle (Ctrl/Cmd-click for multi-select)</div>
|
||||
<select class="input" name="release_ids[]" multiple size="8" required style="height:auto;">
|
||||
<?php foreach ($bundleReleaseOptions as $opt): ?>
|
||||
<option value="<?= (int)($opt['id'] ?? 0) ?>"><?= htmlspecialchars((string)($opt['label'] ?? ''), ENT_QUOTES, 'UTF-8') ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:flex-end;">
|
||||
<button class="btn small" type="submit">Save Bundle</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="admin-card" style="margin-top:12px; padding:14px;">
|
||||
<div class="label" style="margin-bottom:10px;">Existing Bundles</div>
|
||||
<?php if (!$bundles): ?>
|
||||
<div style="color:var(--muted); font-size:13px;">No bundles yet.</div>
|
||||
<?php else: ?>
|
||||
<div style="overflow:auto;">
|
||||
<table style="width:100%; border-collapse:separate; border-spacing:0 8px;">
|
||||
<thead>
|
||||
<tr style="color:var(--muted); font-size:10px; letter-spacing:.14em; text-transform:uppercase; text-align:left;">
|
||||
<th style="padding:0 10px;">Bundle</th>
|
||||
<th style="padding:0 10px;">Slug</th>
|
||||
<th style="padding:0 10px;">Releases</th>
|
||||
<th style="padding:0 10px;">Price</th>
|
||||
<th style="padding:0 10px;">Status</th>
|
||||
<th style="padding:0 10px; text-align:right;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($bundles as $b): ?>
|
||||
<tr style="background:rgba(255,255,255,.02);">
|
||||
<td style="padding:10px; border:1px solid rgba(255,255,255,.08); border-right:none; border-radius:10px 0 0 10px; font-weight:700;"><?= htmlspecialchars((string)($b['name'] ?? ''), ENT_QUOTES, 'UTF-8') ?></td>
|
||||
<td style="padding:10px; border-top:1px solid rgba(255,255,255,.08); border-bottom:1px solid rgba(255,255,255,.08); color:var(--muted); font-size:12px;"><?= htmlspecialchars((string)($b['slug'] ?? ''), ENT_QUOTES, 'UTF-8') ?></td>
|
||||
<td style="padding:10px; border-top:1px solid rgba(255,255,255,.08); border-bottom:1px solid rgba(255,255,255,.08); font-size:12px; color:var(--muted);"><?= (int)($b['release_count'] ?? 0) ?></td>
|
||||
<td style="padding:10px; border-top:1px solid rgba(255,255,255,.08); border-bottom:1px solid rgba(255,255,255,.08); font-size:12px;"><?= htmlspecialchars((string)($b['currency'] ?? 'GBP'), ENT_QUOTES, 'UTF-8') ?> <?= number_format((float)($b['bundle_price'] ?? 0), 2) ?></td>
|
||||
<td style="padding:10px; border-top:1px solid rgba(255,255,255,.08); border-bottom:1px solid rgba(255,255,255,.08);"><span class="pill"><?= (int)($b['is_enabled'] ?? 0) === 1 ? 'active' : 'off' ?></span></td>
|
||||
<td style="padding:10px; border:1px solid rgba(255,255,255,.08); border-left:none; border-radius:0 10px 10px 0; text-align:right;">
|
||||
<form method="post" action="/admin/store/bundles/delete" onsubmit="return confirm('Delete this bundle?');" style="display:inline-flex;">
|
||||
<input type="hidden" name="id" value="<?= (int)($b['id'] ?? 0) ?>">
|
||||
<button class="btn outline small" type="submit" style="border-color:rgba(255,120,120,.45); color:#ffb9b9;">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<form method="post" action="/admin/store/settings" style="margin-top:16px; display:grid; gap:16px;">
|
||||
<input type="hidden" name="tab" value="sales_chart">
|
||||
|
||||
Reference in New Issue
Block a user