Repository navigation
Expand file tree
/
Copy pathorder.php
More file actions
118 lines (96 loc) · 3.82 KB
/
Copy pathorder.php
File metadata and controls
118 lines (96 loc) · 3.82 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
require 'config/conn.php';
require 'include/header.php';
require 'include/auth.php';
?>
<div class="container text-center">
<div class="col-md-5 col-sm-12">
<div class="bigcart"></div>
<h1>Your shopping cart</h1>
<p>
This is a free and <b><a href="http://tutorialzine.com/2014/04/responsive-shopping-cart-layout-twitter-bootstrap-3/" title="Read the article!">responsive shopping cart layout, made by Tutorialzine</a></b>. It looks nice on both desktop and mobile browsers. Try it by resizing your window (or opening it on your smartphone and pc).
</p>
</div>
<div class="col-md-7 col-sm-12 text-left">
<ul>
<li class="row list-inline columnCaptions">
<span>QTY</span>
<span>ITEM</span>
<span>Price</span>
</li>
<?php
if (isset($_SESSION["cart"])) {
$cart = $_SESSION["cart"];
$total = 0;
foreach ($cart as $prodID => $qty) {
//$SQL = $conn->prepare("Select Price * ? as total , Name from Product where Id = ?");
$SQL = $conn->prepare("SELECT
(CASE
WHEN Promotion.Discount is null THEN Product.Price * ?
WHEN Promotion.Discount is not NULL Then Product.Price*(1 - Promotion.Discount) * ?
END) as total, Product.Name, Product.Price as RealPrice
FROM Product
LEFT OUTER JOIN Promotion on Product.Id = Promotion.ProductID
where Product.Id = ?");
$SQL->bindValue("1", $qty);
$SQL->bindValue("2", $qty);
$SQL->bindValue("3", $prodID);
$SQL->execute();
$info = $SQL->fetch();
$total += round($info["total"])
?>
<form id="orderform">
<li class="row">
<span class="quantity">
<div class="form-group row ">
<select name="<?= $prodID ?>" class="form-control" id="sel1">
<option <?= $qty == 0 ? 'selected' : '' ?>>0</option>
<option <?= $qty == 1 ? 'selected' : '' ?>>1</option>
<option <?= $qty == 2 ? 'selected' : '' ?>>2</option>
<option <?= $qty == 3 ? 'selected' : '' ?>>3</option>
<option <?= $qty == 4 ? 'selected' : '' ?> >4</option>
</select>
</div>
</span>
<span class="itemName"><?= $info["Name"] ?></span>
<span class="popbtn"><a class="arrow"></a></span>
<span class="price">$<?= round($info["total"]) ?></span>
</li>
<?
}
$_SESSION["total"] = $total;
}
else {
?>
<h2>Your cart is empty</h2>
<?
}
?>
<li class="row totals">
<span class="itemName">Total:</span>
<span class="price">$<?=isset($total) ? $total : ''?></span>
<span class="order"> <a class="text-center" id="order">Update Cart</a></span>
<span class="order"> <a class="text-center" href="checkout.php" >Procees to Checkout</a></span>
</li>
</ul>
</div>
</form>
</div>
<!-- The popover content -->
<div id="popover" style="display: none">
<a href="#"><span class="glyphicon glyphicon-pencil"></span></a>
<a href="#"><span class="glyphicon glyphicon-remove"></span></a>
</div>
<?php
require 'include/footer.php';
?>
<script>
$(document).ready(function(){
console.log($("#orderform").serialize());
$("#order").click(function() {
$.post("process/updateCart.php", $("#orderform").serialize(), function () {
location.reload();
});
});
});
</script>