![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-50f76f93/ |
<?php
session_start();
header('Content-Type: application/json');
// Include translation system
require_once 'includes/translations.php';
// Get current cart data
$credit_cart = $_SESSION['credit_cart'] ?? [];
$music_cart = $_SESSION['cart'] ?? [];
$ticket_cart = $_SESSION['ticket_cart'] ?? [];
$all_cart_items = array_merge($music_cart, $credit_cart, $ticket_cart);
$has_items = !empty($all_cart_items);
// Build modal body content
ob_start();
if (!$has_items): ?>
<div class="empty-cart">
<i class="fas fa-shopping-bag"></i>
<p>Your cart is empty</p>
<div style="display: flex; gap: 1rem; justify-content: center; margin-top: 1rem;">
<a href="/credits.php" class="btn btn-primary">
<i class="fas fa-plus"></i>
Browse Credit Packages
</a>
<a href="cart.php" class="btn btn-primary">
<i class="fas fa-music"></i>
View Music Cart
</a>
</div>
</div>
<?php else: ?>
<div class="cart-items">
<?php foreach ($all_cart_items as $item): ?>
<div class="cart-item">
<div class="item-info">
<?php if (isset($item['type']) && $item['type'] === 'ticket'): ?>
<h4><?= htmlspecialchars($item['event_title'] ?? 'Event Ticket') ?></h4>
<p><i class="fas fa-ticket-alt"></i> Event Ticket<?= $item['quantity'] > 1 ? 's' : '' ?> × <?= $item['quantity'] ?>
<?php if ($item['is_free'] ?? false): ?>
<span style="color: #48bb78; margin-left: 0.5rem;">(FREE)</span>
<?php endif; ?>
</p>
<?php elseif (isset($item['type']) && $item['type'] === 'credit'): ?>
<h4><?= htmlspecialchars(ucfirst($item['package'])) ?> Package</h4>
<p><i class="fas fa-coins"></i> <?= $item['credits'] ?> credits × <?= $item['quantity'] ?></p>
<?php else: ?>
<h4><?= htmlspecialchars($item['title']) ?></h4>
<p><i class="fas fa-music"></i> by <?= htmlspecialchars($item['artist_name'] ?? $item['artist'] ?? 'Unknown Artist') ?> × <?= $item['quantity'] ?></p>
<?php endif; ?>
</div>
<div class="item-price">
<?php if (isset($item['price'])): ?>
<?php if (($item['is_free'] ?? false) && isset($item['type']) && $item['type'] === 'ticket'): ?>
FREE
<?php else: ?>
$<?= number_format($item['price'] * $item['quantity'], 2) ?>
<?php endif; ?>
<?php endif; ?>
<button class="remove-item-btn" onclick="
<?php
if (isset($item['type']) && $item['type'] === 'ticket'):
echo 'removeTicketFromCart(' . $item['event_id'] . ')';
elseif (isset($item['track_id'])):
echo 'removeFromCart(' . $item['track_id'] . ')';
else:
echo 'removeCreditFromCart(\'' . ($item['package'] ?? '') . '\')';
endif;
?>" title="Remove item">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="cart-total">
<div class="total-row">
<span><i class="fas fa-receipt"></i> Grand Total:</span>
<span>
<?php
$grand_total = array_sum(array_map(function($item) {
return $item['price'] * $item['quantity'];
}, $all_cart_items));
echo $grand_total == 0 ? 'FREE' : '$' . number_format($grand_total, 2);
?>
</span>
</div>
</div>
<?php endif;
$body_content = ob_get_clean();
// Build footer content
ob_start(); ?>
<button onclick="hideCartModal()" class="btn-secondary">
<i class="fas fa-times"></i>
Close
</button>
<?php if ($has_items): ?>
<button onclick="emptyCart()" class="btn-danger">
<i class="fas fa-trash"></i>
Empty Cart
</button>
<button onclick="window.location.href='/checkout.php'" class="btn-primary">
<i class="fas fa-credit-card"></i>
Proceed to Checkout
</button>
<?php endif;
$footer_content = ob_get_clean();
// Calculate total cart count (sum of quantities)
$total_cart_count = 0;
foreach ($all_cart_items as $item) {
$total_cart_count += $item['quantity'] ?? 1;
}
// Return JSON with both body and footer
echo json_encode([
'body' => $body_content,
'footer' => $footer_content,
'has_items' => $has_items,
'cart_count' => $total_cart_count
]);
?>