-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
88 lines (75 loc) · 1.91 KB
/
cart.php
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
<?php
/**
* Created by PhpStorm.
* User: Charles
* Date: 11/17/13
* Time: 2:51 PM
*/
$cartActive = 'class="active"';
include 'header.php';
echo <<<EOD
<h1>Toys In Your Cart</h1>
<h5>
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">Shopping Cart (*Type a number and press ENTER to update Quantity)</div>
<!-- Table -->
<table class="table">
<tr>
<td>#</td>
<td>Toy</td>
<td>Price</td>
<td>Quantity</td>
</tr>
EOD;
$formatted2 = 0;
$n = 0;
$toy = $toyCart->getToyName();
$quantity = $toyCart->getToyQuantity();
$price = $toyCart->getToyPrice();
$discount = $toyCart->getToyDiscount();
$finalPrice = 0;
$subtotal = 0;
for ($j = 0; $j < $toyCart->uniqueToys(); $j++)
{
$toynumber = $n;
$n++;
$finalPrice = ($price[$j] * $discount[$j]);
$subtotal += ($finalPrice * $quantity[$j]);
$formatted = number_format($finalPrice, 2, '.', ',');
$formatted2 = number_format($subtotal, 2, '.', ',');
echo <<<EOD
<tr>
<td>$n</td>
<td>$toy[$j]</td>
<td>\$$formatted</td>
<td><form role="form" method='post' action='cart.php'>
<input type="number" class="form-control" min ='0' max='1000' name='quantity' value='$quantity[$j]'/>
<input type="hidden" name="toynumber" value="$toynumber" />
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
</form>
</td>
</tr>
EOD;
}
echo "</table></div><br>";
echo <<<EOD
<div class="well">Subtotal = $$formatted2</div>
<br>
EOD;
if ($loggedin && $size >=1)
{
echo <<<EOD
<a class="btn btn-warning" href="shipping.php?user=$user">Proceed to checkout</a>
EOD;
}
elseif ($loggedin && $size == 0)
{}
else
{
echo <<<EOD
<a class="btn btn-warning" href="login.php">Please login to checkout</a>
EOD;
}
echo "</h5>";
include 'footer.php';