-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment.php
More file actions
61 lines (54 loc) · 2.05 KB
/
Copy pathpayment.php
File metadata and controls
61 lines (54 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php ob_start();?>
<?php include 'header.php'; ?>
<?php include 'navbar.php'; ?>
<?php include 'core/Amount.php'; ?>
<?php if(!isset($_SESSION))
{
session_start();
}
?>
<div class="container">
<?php
$amount = new Amount();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['items'], $_POST['package'], $_POST['quantities'])) {
$selected_items = $_POST['items'];
$packages = $_POST['package'];
$quantities = $_POST['quantities'];
$_SESSION['total'] = 0;
$items_summary = [];
foreach ($selected_items as $item_id) {
$item = $amount->getOneItem($item_id);
if ($item && isset($quantities[$item_id])) {
$item_total = $item['amount'] * intval($quantities[$item_id]);
$_SESSION['total'] += $item_total;
if (isset($_POST['quantities'][$item_id])) {
$quantity = intval($_POST['quantities'][$item_id]);
} else {
$quantity = 1; // Default quantity if not set
}
$items_summary[] = [
'name' => $item['name'],
'amount' => $item['amount'],
'quantities' => $quantity,
'package' => $packages[$item_id],
'total' => $item_total
];
}
}
// Store the summary in a session to display in summary.php
if(!isset($_SESSION))
{
session_start();
}
$_SESSION['items_summary'] = $items_summary;
//$_SESSION['total'] = $total;
header("Location: summary.php");
exit();
} else {
echo "<p class='alert alert-info my-4'>No items or packages selected.</p>";
}
}
?>
</div>
<?php include 'footer.php'; ?>