From 784b27739c74d214c137cf56a26f3190d416ad49 Mon Sep 17 00:00:00 2001
From: Frank Harris Quantity
Status
Price
+ Action
@@ -518,12 +583,17 @@ $siteBase = $protocol . $host;
-
- x
-
-
- $
-
+
+ x
+
+
+ $
+
+
+
+
@@ -666,6 +736,49 @@ $siteBase = $protocol . $host;
}
}).render('#paypal-button-container');
+
Browse our game servers and add them to your cart to get started!
- Browse Servers -| Game Server | -Duration | -Quantity | -Status | -Price | -
|---|---|---|---|---|
|
-
-
-
-
-
-
-
- |
- - | x | -- - - - | -- $ - | -
Click the button below to complete your purchase securely through PayPal.
- - - - -diff --git a/modules/billing/cart_old.php b/modules/billing/cart_old.php deleted file mode 100644 index 6492221c..00000000 --- a/modules/billing/cart_old.php +++ /dev/null @@ -1,564 +0,0 @@ -= intval($coupon['max_uses'])) { - $max_uses_reached = true; - } - } - - if ($expired) { - $coupon_error = 'This coupon has expired.'; - } elseif ($max_uses_reached) { - $coupon_error = 'This coupon has reached its maximum usage limit.'; - } else { - // Check game filter - $game_valid = true; - if ($coupon['game_filter_type'] === 'specific_games' && !empty($coupon['game_filter_list'])) { - $allowed_games = json_decode($coupon['game_filter_list'], true); - if (is_array($allowed_games) && count($allowed_games) > 0) { - // Check if any invoice game is in allowed list - $has_valid_game = false; - foreach ($invoices as $inv) { - if (in_array($inv['game_key'], $allowed_games)) { - $has_valid_game = true; - break; - } - } - if (!$has_valid_game) { - $game_valid = false; - } - } - } - - if (!$game_valid) { - $coupon_error = 'This coupon is not valid for the items in your cart.'; - } else { - // Apply coupon (stored in session, applied at checkout) - $applied_coupon = $coupon; - $coupon_code = $submitted_code; - $coupon_discount_percent = floatval($coupon['discount_percent']); - $_SESSION['cart_coupon_code'] = $coupon_code; - $_SESSION['cart_coupon_id'] = $coupon['coupon_id']; - $coupon_success = 'Coupon "' . htmlspecialchars($coupon['name']) . '" applied! You save ' . $coupon_discount_percent . '%'; - } - } - } else { - $coupon_error = 'Invalid coupon code.'; - } - } - } -} - -// Handle coupon removal -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['remove_coupon'])) { - unset($_SESSION['cart_coupon_code']); - unset($_SESSION['cart_coupon_id']); - $coupon_code = ''; - $coupon_discount_percent = 0; - $applied_coupon = null; -} - -// Calculate discount if coupon is applied -// Calculate discount if coupon is applied -$discount_amount = 0; -if (!empty($coupon_code) && $coupon_discount_percent > 0 && $db) { - // Re-validate the coupon from session - $safe_code = mysqli_real_escape_string($db, $coupon_code); - $coupon_query = "SELECT * FROM {$table_prefix}billing_coupons - WHERE code = '$safe_code' AND is_active = 1"; - $coupon_result = mysqli_query($db, $coupon_query); - - if ($coupon_result && mysqli_num_rows($coupon_result) === 1) { - $applied_coupon = mysqli_fetch_assoc($coupon_result); - $coupon_discount_percent = floatval($applied_coupon['discount_percent']); - $discount_amount = $total_amount * ($coupon_discount_percent / 100); - } -} else { - // No DB or no coupon: ensure discount is zero - $discount_amount = 0; -} - -$final_amount = $total_amount - $discount_amount; - -// PayPal configuration -$sandbox = true; // Set to false for live PayPal -$client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c'; - -// Prepare PayPal items array -$paypal_items = []; -foreach ($invoices as $inv) { - $game_display = !empty($inv['game_name']) ? $inv['game_name'] : 'Game Server'; - $paypal_items[] = [ - 'name' => $inv['home_name'] . ' (' . $game_display . ')', - 'description' => $inv['description'], - 'quantity' => intval($inv['qty']), - 'unit_amount' => [ - 'currency_code' => 'USD', - 'value' => number_format(floatval($inv['amount']) / intval($inv['qty']), 2, '.', '') - ] - ]; -} - -// Get site base URL dynamically -$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://'; -$host = $_SERVER['HTTP_HOST'] ?? 'localhost'; -$siteBase = $protocol . $host; - -if ($db) mysqli_close($db); -?> - - -
- - -
- - - - - - -
-