diff --git a/wp-ingame-shop/wp-ingame-shop-pro.php b/wp-ingame-shop/wp-ingame-shop-pro.php index 4484928..fa7b671 100644 --- a/wp-ingame-shop/wp-ingame-shop-pro.php +++ b/wp-ingame-shop/wp-ingame-shop-pro.php @@ -3,7 +3,7 @@ Plugin Name: WP Ingame Shop Pro Plugin URI:https://git.viper.ipv64.net/M_Viper/WP-Ingame-Shop-Pro Description: Vollautomatischer Shop mit Warenkorb (kein echtgeld Handel) -Version: 2.1.4 +Version: 2.1.3 Author: M_Viper Author URI: https://m-viper.de Requires at least: 6.9.1 @@ -20,7 +20,7 @@ Support: [Telegram Support](https://t.me/M_Viper04) if (!defined('ABSPATH')) exit; // Plugin Constants -define('WIS_VERSION', '2.1.4'); +define('WIS_VERSION', '2.1.3'); define('WIS_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('WIS_PLUGIN_URL', plugin_dir_url(__FILE__)); @@ -137,6 +137,10 @@ class WIS_Dashboard { ?> prefix . 'wis_coupons'; + $codes = $wpdb->get_results($wpdb->prepare( + "SELECT code, value, type, usage_limit, expiry, min_order_value FROM $table WHERE bulk_id = %s ORDER BY id ASC", + $bulk_id + )); + if ($codes) { + header('Content-Type: text/csv; charset=utf-8'); + header('Content-Disposition: attachment; filename="gutscheine-' . $bulk_id . '.csv"'); + $out = fopen('php://output', 'w'); + fprintf($out, chr(0xEF).chr(0xBB).chr(0xBF)); // UTF-8 BOM + fputcsv($out, ['Code', 'Rabatt', 'Typ', 'Max. Einlösungen', 'Gültig bis', 'Mindestbestellwert'], ';'); + foreach ($codes as $c) { + fputcsv($out, [ + $c->code, + $c->value, + $c->type === 'percent' ? 'Prozent' : 'Fest', + $c->usage_limit, + $c->expiry ?: '∞', + $c->min_order_value ?: '–' + ], ';'); + } + fclose($out); + exit; + } + } + + // ── Bulk-Generierung speichern ──────────────────────────────────────── + if (isset($_POST['wis_bulk_generate'])) { + check_admin_referer('wis_bulk_generate'); + global $wpdb; + + $count = min(500, max(1, intval($_POST['bulk_count'] ?? 10))); + $mode = $_POST['bulk_mode'] === 'prefix' ? 'prefix' : 'random'; + $prefix = strtoupper(preg_replace('/[^A-Z0-9_-]/i', '', $_POST['bulk_prefix'] ?? '')); + $value = intval($_POST['bulk_value'] ?? 10); + $type = in_array($_POST['bulk_type'], ['fixed', 'percent']) ? $_POST['bulk_type'] : 'fixed'; + $usage_limit = max(1, intval($_POST['bulk_usage_limit'] ?? 1)); + $expiry = !empty($_POST['bulk_expiry']) ? sanitize_text_field($_POST['bulk_expiry']) : null; + $min_order = intval($_POST['bulk_min_order'] ?? 0); + $allowed_cats = !empty($_POST['bulk_allowed_categories']) + ? implode(',', array_map('intval', (array)$_POST['bulk_allowed_categories'])) + : null; + + $bulk_id = strtoupper(bin2hex(random_bytes(4))); // gemeinsame ID für diese Batch + $table = $wpdb->prefix . 'wis_coupons'; + $generated = 0; + $skipped = 0; + $attempts = 0; + + while ($generated < $count && $attempts < $count * 5) { + $attempts++; + if ($mode === 'prefix' && $prefix) { + $rand = strtoupper(bin2hex(random_bytes(4))); + $code = $prefix . '-' . substr($rand, 0, 3) . '-' . substr($rand, 3, 5); + } else { + $r = strtoupper(bin2hex(random_bytes(6))); + $code = substr($r, 0, 4) . '-' . substr($r, 4, 4) . '-' . substr($r, 8, 4); + } + // Duplikat-Check + $exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM $table WHERE code = %s", $code)); + if ($exists) { $skipped++; continue; } + + $wpdb->insert($table, [ + 'code' => $code, + 'value' => $value, + 'type' => $type, + 'usage_limit' => $usage_limit, + 'used_count' => 0, + 'expiry' => $expiry, + 'min_order_value' => $min_order, + 'allowed_categories'=> $allowed_cats, + 'bulk_id' => $bulk_id, + ]); + if ($wpdb->insert_id) $generated++; + } + + $export_url = wp_nonce_url( + admin_url('admin.php?page=wis_coupons&action=export_bulk&bulk_id=' . $bulk_id), + 'wis_coupon_action', '_wpnonce' + ); + echo '
'; + echo "{$generated} Gutscheine wurden generiert"; + if ($skipped) echo " ({$skipped} Duplikate übersprungen)"; + echo '. 📥 Als CSV exportieren
Optional
+Gutschein gilt nur ab diesem Bestellwert (0 = kein Minimum). Wert in .
+Ohne Auswahl gilt der Gutschein für alle Kategorien.
+@@ -2679,43 +3449,198 @@ class WIS_Admin { $coupons = WIS_DB::get_coupons(); $currency = get_option('wis_currency_name', 'Coins'); + global $wpdb; + $uses_table = $wpdb->prefix . 'wis_coupon_uses'; + $uses_exists = $wpdb->get_var("SHOW TABLES LIKE '$uses_table'"); + // Alle Einlösungen laden (gruppiert nach coupon_id) + $uses_by_coupon = []; + if ($uses_exists) { + $all_uses = $wpdb->get_results("SELECT coupon_id, player_name, used_at FROM $uses_table ORDER BY used_at DESC"); + foreach ($all_uses as $u) { + $uses_by_coupon[$u->coupon_id][] = $u; + } + } ?>
| Bulk-ID | +Codes | +Rabatt | +Gültig bis | +Aktionen | +
|---|---|---|---|---|
|
+ + | value); ?>type==='percent'?'%':' '.esc_html(get_option('wis_currency_name','Coins')); ?> | +expiry ? esc_html(date('d.m.Y', strtotime($sample->expiry))) : '∞'; ?> | +📥 CSV Export | +
| Code | -Rabatt | -Genutzt | -Gültig bis | -Aktionen | +Code | +Rabatt | +Genutzt | +Gültig bis | +Eingelöst von | +Aktionen |
|---|---|---|---|---|---|---|---|---|---|---|
| Noch keine Gutscheine vorhanden. | ||||||||||
| code); ?> | -- type === 'percent'): ?> - value); ?>% - - value); ?> - - | -used_count); ?> / usage_limit); ?> | -expiry ? esc_html(date('d.m.Y', strtotime($coupon->expiry))) : '∞'; ?> | -- Bearbeiten - Löschen - | -||||||
| Noch keine Gutscheine vorhanden. | ||||||||||
| + code); ?> + bulk_id)): ?> + BULK + + | ++ type === 'percent'): ?> + value); ?>% + + value); ?> + + | +used_count); ?> / usage_limit); ?> | +expiry ? esc_html(date('d.m.Y', strtotime($coupon->expiry))) : '∞'; ?> | +
+
+ –
+
+
+
+
+ player_name); ?>
+
+
+
+
+ |
+ + Bearbeiten + Löschen + | +|||||
✅ Bestellung gelöscht!
✅ Status geändert!
Bestellung nicht gefunden.
Bestellung nicht gefunden.
| ID | id); ?> |
|---|---|
| Datum | created_at))); ?> |
| Käufer | player_name); ?> |
| 🎁 Geschenk für | gift_recipient); ?> |
| 🎁 Geschenk für | gift_recipient); ?> |
| Server | server); ?> |
| Zusammenfassung | item_title); ?> |
| Preis | price); ?> |
| Status | status] ?? $order->status; ?> |
| Details (JSON) | -response); ?> |
-
| Status | status] ?? $order->status; ?> |
| Details (JSON) | response); ?> |
| Datum | -Käufer | -Empfänger | +ID | +Datum | +Käufer | +Empfänger | +Server | Inhalt | -Preis | -Status | -Aktionen | +Preis | +Status | +Aktionen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Noch keine Bestellungen vorhanden. | ||||||||||||||
| created_at))); ?> | -player_name); ?> | -gift_recipient)): ?>🎁 gift_recipient); ?>– | -item_title, 0, 50)) . (strlen($order->item_title) > 50 ? '...' : ''); ?> | -price); ?> | -status] ?? $order->status; ?> | -- 👁️ Details - 🗑️ Löschen - | -||||||||
| Keine Bestellungen gefunden. | ||||||||||||||
| #id; ?> | +created_at)); ?> | +player_name); ?> | +gift_recipient)): ?>🎁 gift_recipient); ?>– | +server); ?> | +item_title, 0, 55)) . (mb_strlen($order->item_title) > 55 ? '…' : ''); ?> | +price); ?> | +status] ?? $order->status; ?> | ++ Details + " class="button button-small" onclick="return confirm('Wirklich löschen?');" style="color:red;">Löschen + | +||||||
Tabelle noch nicht vorhanden – Plugin einmal deaktivieren/aktivieren.
| Datum | +Spieler | +Server | +Item | +Menge | +Ø Preis | +Ausgezahlt | +
|---|---|---|---|---|---|---|
| Keine Einträge gefunden. | ||||||
| sold_at)); ?> | +player_name); ?> | +server); ?> | +item_name); ?>item_id); ?> | +quantity); ?> | +price_per_item, 2); ?> | +total_paid, 2); ?> | +
Tabelle noch nicht vorhanden – Plugin einmal deaktivieren/aktivieren.
Noch keine Preisänderungen protokolliert. Ändere einen Preis bei einem Item und speichere – ab dann wird hier alles festgehalten.
+ +| Datum | +Item | +Feld | +Alt | +Neu | +Diff | +Geändert von | +
|---|---|---|---|---|---|---|
| Keine Einträge gefunden. | ||||||
| changed_at)); ?> | +item_name); ?>item_id); ?> | +field); ?> | +old_value); ?> | +new_value); ?> | +0?'+':'') . number_format($diff); ?> | +changed_by); ?> | +