-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddCart.php
143 lines (137 loc) · 6.19 KB
/
addCart.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
require_once __DIR__. "/autoload/autoload.php";
if(!isset($_SESSION['email']))
{
header("Location: http://localhost/fruitstore/loginForm.php");
$_SESSION['fail'] = "Please login first !";
}
else
{
$id = intval(getInput('id'));
// echo $id;
}
?>
<?php require_once __DIR__. "/layouts/header.php";?>
<!-- //////////////////////////////////////////// -->
<!-- Breadcrumb Section Begin -->
<section class="breadcrumb-section set-bg" data-setbg="public/frontend/img/breadcrumb.jpg">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<div class="breadcrumb__text">
<h2>Shopping Cart</h2>
<div class="breadcrumb__option">
<a href="index.php">Home</a>
<span>Shopping Cart</span>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Breadcrumb Section End -->
<!-- Shoping Cart Section Begin -->
<section class="shoping-cart spad">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="shoping__cart__table">
<table>
<thead>
<tr>
<th class="shoping__product">Products</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<?php if(count($_SESSION['cart']) > 0) : ?>
<?php foreach($_SESSION['cart'] as $key => $item): ?>
<tr>
<td class="shoping__cart__item">
<img width="80px" height="80px" src="public/uploads/products/<?php echo $item['image'] ?>" alt="">
<h5><?php echo $item['name'] ?></h5>
</td>
<td class="shoping__cart__price">
<?php echo formatPrice($item['price']) ?> VND
</td>
<td class="shoping__cart__quantity">
<div class="quantity">
<div class="pro-qty">
<input
name="quantity"
id="quantity"
type="number"
value="<?php echo $item['quantity'] ?>"
min="1"
>
</div>
</div>
</td>
<td class="shoping__cart__total">
<?php echo formatPrice($item['price']*$item['quantity']) ?> VND
</td>
<!-- Remove item -->
<td class="shoping__cart__item__close">
<a href="remove.php?key=<?php echo $key ?>">
<span class="fas fa-ban"></span>
</a>
</td>
<!-- Update quantity -->
<td class="shoping__cart__item__close ">
<a id="update_btn" data-key ="<?php echo $key ?>" href="">
<span class="fa fa-sync "></span>
</a>
</td>
</tr>
<?php endforeach;?>
<?php else :?>
<tr>
<td class="shoping__cart__price" style="text-align: left; width : 30%">Buy something ...</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="shoping__cart__btns">
<a href="index.php" class="primary-btn cart-btn">CONTINUE SHOPPING</a>
<a href="index.php" class="primary-btn cart-btn cart-btn-right">CONTINUE SHOPPING</a></div>
</div>
<div class="col-lg-6">
<div class="shoping__continue">
<div class="shoping__discount">
<h5>Discount Codes</h5>
<form action="#">
<input type="text" placeholder="Enter your coupon code">
<button type="submit" class="site-btn">APPLY COUPON</button>
</form>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="shoping__checkout">
<h5>Cart Total</h5>
<?php if(isset($_SESSION['cart'])) : ?>
<?php $subtotal =0; ?>
<?php foreach($_SESSION['cart'] as $item) : ?>
<?php $subtotal += ($item['price']*$item['quantity']) ?>
<?php endforeach; ?>
<ul>
<li>Total <span><?php $_SESSION['total_price'] = $subtotal ;echo formatPrice($subtotal) ?> VND</span></li>
</ul>
<?php endif; ?>
<a href="cartCheckout.php" class="primary-btn">CHECKOUT</a>
</div>
</div>
</div>
</div>
</section>
<!-- Shoping Cart Section End -->
<?php require_once __DIR__. "/layouts/footer.php";?>