-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcart.php
116 lines (108 loc) · 3.46 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
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
<?php
session_start();
ob_start();
$rootPath = '/ananas';
require_once './database/DB.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Giỏ hàng - Ananas</title>
<link rel="icon" type="image/x-icon" href="https://brademar.com/wp-content/uploads/2022/09/Ananas-Logo-PNG-1.png">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.1.2/css/all.css">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="./public/css/base.css">
<!-- <link rel="stylesheet" href="./public/css/home.css"> -->
</head>
<body>
<?php
require './includes/header.php';
require './includes/navbar.php';
?>
<!-- giỏ hàng -->
<div id="cart"></div>
<?php
// end giỏ hàng
require './includes/footer.php';
?>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"
integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="./public/javascripts/loadCart.js"></script>
<script>
$(document).ready(function() {
loadCartAjax();
$(window).scroll(function() {
if ($(this).scrollTop() > 114) {
$("#navbar-top").addClass('fix-nav')
} else {
$("#navbar-top").removeClass('fix-nav')
}
})
});
// tăng số lượng
function addCartQty(pId) {
var id = pId;
console.log(id);
$.ajax({
url: "<?=$rootPath?>/ajax/addCartQty.php",
type: "POST",
data: {
productId: id,
},
success: function(data) {
loadCartAjax();
},
error: function() {
alert("Lỗi thao tác");
}
});
}
// Giảm số lượng
function subCartQty(pId) {
var id = pId;
console.log(id);
$.ajax({
url: "<?=$rootPath?>/ajax/subCartQty.php",
type: "POST",
data: {
productId: id,
},
success: function(data) {
loadCartAjax();
},
error: function() {
alert("Lỗi thao tác");
}
});
}
function deleteCartItem(pId) {
var id = pId;
console.log(id);
$.ajax({
url: "<?=$rootPath?>/ajax/deleteCartItem.php",
type: "POST",
data: {
productId: id,
},
success: function(data) {
loadCartAjax();
},
error: function() {
alert("Lỗi thao tác");
}
});
}
</script>
<script src="./public/javascripts/liveSearch.js"></script>
</body>
</html>