Upload via Git Manager GUI

This commit is contained in:
Git Manager GUI
2026-04-29 21:06:12 +02:00
parent 798abcc0f2
commit 30427f7bb3

View File

@@ -374,6 +374,8 @@ class WIS_Activator {
'wis_daily_deal_enabled' => '0',
'wis_daily_deal_discount' => '20',
'wis_api_key' => bin2hex(random_bytes(24)),
'wis_tax_enabled' => '0',
'wis_tax_rate' => '0',
];
foreach ($defaults as $key => $value) {
@@ -1230,6 +1232,8 @@ class WIS_Admin {
update_option('wis_daily_deal_enabled', isset($_POST['wis_daily_deal_enabled']) ? '1' : '0');
update_option('wis_daily_deal_discount', intval($_POST['wis_daily_deal_discount']));
update_option('wis_offline_queue_enabled', isset($_POST['wis_offline_queue_enabled']) ? '1' : '0');
update_option('wis_tax_enabled', isset($_POST['wis_tax_enabled']) ? '1' : '0');
update_option('wis_tax_rate', max(0, min(100, floatval(str_replace(',', '.', $_POST['wis_tax_rate'] ?? '0')))));
echo '<div class="updated"><p>✅ Einstellungen gespeichert!</p></div>';
}
@@ -1357,6 +1361,24 @@ class WIS_Admin {
<p class="description">Erfordert Spigot-Plugin v6.3+ mit Offline-Queue-Unterstützung</p>
</td>
</tr>
<tr>
<th>Steuer aktivieren</th>
<td>
<label>
<input type="checkbox" name="wis_tax_enabled" value="1" <?php checked(get_option('wis_tax_enabled', '0'), '1'); ?>>
Steuer auf den Endbetrag aufschlagen (nach Gutschein-Abzug)
</label>
</td>
</tr>
<tr>
<th><label for="wis_tax_rate">Steuersatz (%)</label></th>
<td>
<input type="number" id="wis_tax_rate" name="wis_tax_rate"
value="<?php echo esc_attr(get_option('wis_tax_rate', '0')); ?>"
min="0" max="100" step="0.01" style="width:100px;">
<p class="description">Z.B. <code>19</code> für 19 % MwSt. Nur aktiv wenn „Steuer aktivieren" angehakt ist.</p>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" name="wis_save_settings" class="button button-primary" value="Einstellungen speichern">
@@ -3555,6 +3577,16 @@ class WIS_API {
$final_price = max(0, $total_normal - $coupon_discount) + $total_offer;
// ── Steuer ──────────────────────────────────────────────────
$tax_enabled = get_option('wis_tax_enabled', '0');
$tax_rate = floatval(get_option('wis_tax_rate', '0'));
$tax_amount = 0;
if ($tax_enabled === '1' && $tax_rate > 0) {
$tax_amount = floor($final_price * $tax_rate / 100);
$final_price = $final_price + $tax_amount;
}
// ────────────────────────────────────────────────────────────
// Fly-Dauern (item_id → Sekunden)
// Fly-Dauern und lesbares Label (wird dem Spieler auf dem Code angezeigt)
$fly_durations = [
@@ -3936,6 +3968,17 @@ class WIS_Shortcode {
<div id="coupon-msg" class="wis-coupon-msg"></div>
</div>
<div id="wis-tax-breakdown" style="display:none; background:#f8f9fa; border-radius:6px; padding:10px 15px; margin-bottom:8px;">
<div style="display:flex; justify-content:space-between; margin-bottom:4px; color:#555; font-size:0.95rem;">
<span>Zwischensumme:</span>
<span id="cart-subtotal">0 <?php echo esc_html($currency); ?></span>
</div>
<div style="display:flex; justify-content:space-between; color:#e67e22; font-size:0.95rem;">
<span>⚖️ Steuer (<?php echo esc_attr(get_option('wis_tax_rate', '0')); ?>%):</span>
<span id="cart-tax">0 <?php echo esc_html($currency); ?></span>
</div>
</div>
<div class="wis-cart-total">
<span>Gesamt:</span>
<span id="cart-total">0 <?php echo esc_html($currency); ?></span>
@@ -3964,6 +4007,8 @@ class WIS_Shortcode {
(function() {
const shopCurrency = <?php echo json_encode($currency); ?>;
const shopExcludeOffers = <?php echo $exclude_offers === '1' ? 'true' : 'false'; ?>;
const shopTaxEnabled = <?php echo get_option('wis_tax_enabled', '0') === '1' ? 'true' : 'false'; ?>;
const shopTaxRate = <?php echo floatval(get_option('wis_tax_rate', '0')); ?>;
const apiBase = <?php echo json_encode(rest_url('wis/v1')); ?>;
const serverList = <?php echo json_encode(array_map(function($s){ return ['slug'=>$s->slug,'name'=>$s->name]; }, $servers)); ?>;
@@ -4268,7 +4313,7 @@ class WIS_Shortcode {
document.getElementById('cart-modal').style.display = 'none';
}
function calculateTotal() {
function calculateSubtotal() {
var normal = 0, offer = 0;
cart.forEach(function(item) {
var t = item.price * item.quantity;
@@ -4283,6 +4328,16 @@ class WIS_Shortcode {
return Math.max(0, normal - discount) + offer;
}
function calculateTax(subtotal) {
if (!shopTaxEnabled || shopTaxRate <= 0) return 0;
return Math.floor(subtotal * shopTaxRate / 100);
}
function calculateTotal() {
var subtotal = calculateSubtotal();
return subtotal + calculateTax(subtotal);
}
function renderCart() {
var content = document.getElementById('cart-content');
var checkout = document.getElementById('cart-checkout');
@@ -4312,6 +4367,19 @@ class WIS_Shortcode {
});
document.getElementById('cart-total').textContent = calculateTotal() + ' ' + shopCurrency;
// Steuer-Aufschlüsselung
var taxBreakdown = document.getElementById('wis-tax-breakdown');
if (shopTaxEnabled && shopTaxRate > 0 && taxBreakdown) {
var sub = calculateSubtotal();
var tax = calculateTax(sub);
document.getElementById('cart-subtotal').textContent = sub + ' ' + shopCurrency;
document.getElementById('cart-tax').textContent = tax + ' ' + shopCurrency;
taxBreakdown.style.display = 'block';
} else if (taxBreakdown) {
taxBreakdown.style.display = 'none';
}
checkout.style.display = 'block';
}