%PDF- %PDF-
Direktori : /home/medipszd/public_html/ |
Current File : //home/medipszd/public_html/cart_total.php |
<?php include 'includes/session.php'; if(isset($_SESSION['user'])){ $conn = $pdo->open(); $stmt = $conn->prepare("SELECT * FROM cart LEFT JOIN products on products.id=cart.product_id WHERE user_id=:user_id"); $stmt->execute(['user_id'=>$user['id']]); $total = 0; foreach($stmt as $row){ $subtotal = $row['price'] * $row['quantity']; $total += $subtotal; } $pdo->close(); echo json_encode($total); } ?>