-
Notifications
You must be signed in to change notification settings - Fork 0
/
products.php
91 lines (88 loc) · 2.34 KB
/
products.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
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en"><head>
<title>Products</title>
<link href="styles/style.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="styles/applicationStyles.css">
<style type="text/css">
.active {
background-color: #4CAF50;
color: white;
}
</style>
<script type="text/javascript">
var checkout = function(){
var customerName = prompt("Enter customer name: ", "");
while (customerName == null || customerName == "") {
alert("Please provide the customer name");
customerName = prompt("Enter customer name: ", "");
}
cartAction('empty',customerName);
}
</script>
</head>
<body>
<div class="header">
<div class="title">
<h1>Welcome to Home Shop</h1>
<p>Various needs one destination</p>
</div>
<div class="titleImage">
<img src="images/headingImage.jpg">
</div>
<div >
<a href="index.php">Home</a>
<a class="products.php" href="#news">Products</a>
<a href="feedback.php">Contact Us</a>
</div>
</div>
<?php
require_once "product-gallery.php";
?>
<div class="clear-float"></div>
<div id="shopping-cart">
<div id="cart-item">
<?php
require_once "ajax-action.php";
?>
</div>
</div>
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script>
function cartAction(action, product_code) {
var queryString = "";
if (action != "") {
switch (action) {
case "add":
queryString = 'action=' + action + '&code=' + product_code
+ '&quantity=' + $("#qty_" + product_code).val();
break;
case "remove":
queryString = 'action=' + action + '&code=' + product_code;
break;
case "empty":
queryString = 'action=' + action + '&customerName=' + product_code;;
break;
}
}
jQuery.ajax({
url : "ajax-action.php",
data : queryString,
type : "POST",
success : function(data) {
$("#cart-item").html(data);
if (action == "add") {
$("#add_" + product_code + " img").attr("src",
"images/icon-check.png");
$("#add_" + product_code).attr("onclick", "");
}
},
error : function() {
}
});
}
</script>
</body>
</html>