![]() 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/domains/soundstudiopro.com/private_html/ |
<?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><?= t('common.empty_cart') ?></p>
<div class="empty-cart-cta-group">
<a href="/credits.php" class="empty-cart-cta primary">
<span class="cta-icon"><i class="fas fa-coins"></i></span>
<span><?= t('credits.browse_packages') ?></span>
</a>
<a href="/events.php" class="empty-cart-cta secondary">
<span class="cta-icon"><i class="fas fa-ticket-alt"></i></span>
<span><?= t('events.browse_tickets') ?></span>
</a>
<a href="cart.php" class="empty-cart-cta tertiary">
<span class="cta-icon"><i class="fas fa-shopping-basket"></i></span>
<span><?= t('common.view_cart') ?></span>
</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'] ?? t('events.ticket')) ?></h4>
<p><i class="fas fa-ticket-alt"></i> <?= t('events.ticket') ?><?= $item['quantity'] > 1 ? 's' : '' ?> × <?= $item['quantity'] ?>
<?php if ($item['is_free'] ?? false): ?>
<span style="color: #48bb78; margin-left: 0.5rem;">(<?= t('common.free') ?>)</span>
<?php endif; ?>
</p>
<?php elseif (isset($item['type']) && $item['type'] === 'credit'): ?>
<h4><?= htmlspecialchars(ucfirst($item['package'])) ?> <?= t('checkout.package') ?></h4>
<p><i class="fas fa-coins"></i> <?= $item['credits'] ?> <?= t('common.credits') ?> × <?= $item['quantity'] ?></p>
<?php else: ?>
<h4>
<?php if (isset($item['track_id'])): ?>
<a href="/track.php?id=<?= $item['track_id'] ?>" style="color: inherit; text-decoration: none; transition: color 0.3s;" onmouseover="this.style.color='#667eea';" onmouseout="this.style.color='inherit';">
<?= htmlspecialchars($item['title']) ?>
</a>
<?php else: ?>
<?= htmlspecialchars($item['title']) ?>
<?php endif; ?>
</h4>
<p><i class="fas fa-music"></i> <?= t('checkout.by') ?>
<?php if (isset($item['artist_id'])): ?>
<a href="/artist_profile.php?id=<?= $item['artist_id'] ?>" class="no-ajax" style="color: inherit; text-decoration: none; transition: color 0.3s;" onmouseover="this.style.color='#667eea';" onmouseout="this.style.color='inherit';">
<?= htmlspecialchars($item['artist_name'] ?? $item['artist'] ?? t('checkout.unknown_artist')) ?>
</a>
<?php else: ?>
<?= htmlspecialchars($item['artist_name'] ?? $item['artist'] ?? t('checkout.unknown_artist')) ?>
<?php endif; ?>
× <?= $item['quantity'] ?>
</p>
<?php endif; ?>
</div>
<div class="item-price">
<div class="quantity-controls">
<?php if (isset($item['type']) && $item['type'] === 'track'): ?>
<span class="quantity-display"><?= $item['quantity'] ?></span>
<span class="single-quantity-note"><?= t('cart.single_quantity_note') ?></span>
<?php else: ?>
<button class="qty-btn qty-decrease" onclick="updateCartModalQuantity('<?= isset($item['type']) ? $item['type'] : 'track' ?>', '<?= isset($item['type']) && $item['type'] === 'ticket' ? $item['event_id'] : (isset($item['track_id']) ? $item['track_id'] : ($item['package'] ?? '')) ?>', -1)" title="<?= t('checkout.decrease_quantity') ?>" <?= $item['quantity'] <= 1 ? 'disabled' : '' ?>>
<i class="fas fa-minus"></i>
</button>
<span class="quantity-display"><?= $item['quantity'] ?></span>
<button class="qty-btn qty-increase" onclick="updateCartModalQuantity('<?= isset($item['type']) ? $item['type'] : 'track' ?>', '<?= isset($item['type']) && $item['type'] === 'ticket' ? $item['event_id'] : (isset($item['track_id']) ? $item['track_id'] : ($item['package'] ?? '')) ?>', 1)" title="<?= t('checkout.increase_quantity') ?>">
<i class="fas fa-plus"></i>
</button>
<?php endif; ?>
</div>
<?php if (isset($item['price'])): ?>
<div style="font-size: 1.5rem; font-weight: 700; color: white;">
<?php if (($item['is_free'] ?? false) && isset($item['type']) && $item['type'] === 'ticket'): ?>
<?= t('common.free') ?>
<?php else: ?>
$<?= number_format($item['price'] * $item['quantity'], 2) ?>
<?php endif; ?>
</div>
<?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="<?= t('checkout.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> <?= t('checkout.grand_total') ?>:</span>
<span>
<?php
$grand_total = array_sum(array_map(function($item) {
return ($item['price'] ?? 0) * ($item['quantity'] ?? 0);
}, $all_cart_items));
echo $grand_total == 0 ? t('common.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>
<?= t('btn.close') ?>
</button>
<?php if ($has_items): ?>
<button onclick="emptyCart()" class="btn-danger">
<i class="fas fa-trash"></i>
<?= t('credits.clear_cart') ?>
</button>
<button onclick="window.location.href='/checkout.php'" class="btn-primary">
<i class="fas fa-credit-card"></i>
<?= t('checkout.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
]);
?>