-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
54 lines (47 loc) · 1.25 KB
/
checkout.php
File metadata and controls
54 lines (47 loc) · 1.25 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
<?php
require_once "templates/page_setup.php";
$page_name = "checkout";
include "templates/header.php";
include "templates/jumbotron.php";
?>
<?php
if (isset($_POST['check'])){
$users = User::readUsers(); //get users from users.csv
foreach ($users as $u){
if ($u->status == 'Admin'){
$to = $u->email;
$subject = 'Customer Purchase';
$message = 'Customer Purchased some items from the store!';
mail($to,$subject,$message);
}
}
clear_cart();
//header('Location: cart.php');
echo '<h2 align="center">Thanks for Shopping With Us!</h2>';
echo '<p align="center"><a href="products.php">Back To Shopping</a></p>';
include 'templates/footer.php';
die();
}
function clear_cart(){
unset($_SESSION['array']);
unset($_SESSION['items']);
}
?>
<?php
function total (){
$total = 0.0;
$row = $_SESSION['array'];
foreach ($row as $ing){
$total += $_SESSION['items'][$ing->id]['Total'];
}
return $total;
}
?>
<div class="checkout">
<h1 align="center">Your Total is $<?php echo number_format((float)total(), 2 , '.' , '');?></h1>
<h2 align="center">Are You Sure You Want To Checkout?</h2>
<form action="#" method="post">
<input type="submit" name="check" value="Checkout">
</form>
</div>
<?php require 'templates/footer.php';?>