<?php // === Datei: admin/rabatte.php === $file = __DIR__ . '/rabatte.json'; // Falls Datei nicht existiert -> leere anlegen if (!file_exists($file)) { file_put_contents($file, json_encode([], JSON_PRETTY_PRINT)); } // Aktionen: speichern, löschen if ($_SERVER['REQUEST_METHOD'] === 'POST') { $codes = json_decode(file_get_contents($file), true); if (isset($_POST['action']) && $_POST['action'] === 'save') { $code = strtoupper(trim($_POST['code'])); $type = $_POST['type']; $value = floatval($_POST['value']); $codes[$code] = ['type' => $type, 'value' => $value]; file_put_contents($file, json_encode($codes, JSON_PRETTY_PRINT)); } elseif (isset($_POST['action']) && $_POST['action'] === 'delete') { $code = $_POST['code']; unset($codes[$code]); file_put_contents($file, json_encode($codes, JSON_PRETTY_PRINT)); } header("Location: rabatte.php"); exit; } // Codes laden $codes = json_decode(file_get_contents($file), true); ?> Rabattcode-Verwaltung – Klapré Studio

Rabattcode-Verwaltung

<?php if (empty($codes)): ?>

Keine Rabattcodes vorhanden.

<?php else: ?> <?php foreach ($codes as $code => $data): ?> <?php endforeach; ?>
CodeTypWertAktion
<?= htmlspecialchars($code) ?> <?= htmlspecialchars($data['type']) ?> <?= htmlspecialchars($data['value']) ?><?= $data['type']=='percent'?'%':' €' ?>
<?php endif; ?>

Neuen Code hinzufügen







ImpressumDatenschutzinformation