-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproduct.php
115 lines (100 loc) · 4.01 KB
/
product.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
<?php
session_start();
include_once 'isAuthentificated.php';
include_once 'autoload.php';
$productrep = new ProductRepository();
$productImgrep = new ProductImageRepository();
if (isset($_GET['view'])) {
$product = $productrep->findOneBy(array('id' => $_GET['view']));
$images = $productImgrep->findBy(array('productId' => $product['id']));
} else {
header("Location:shopping.php");
}
$pageName=$product['name'];
include_once 'assets/mainHead.php';
?>
<link rel="stylesheet" href="css/product.css">
</head>
<body>
<?php include_once 'navbarCo.php' ?>
<?php include_once 'preloader.php' ?>
<div class="product">
<h1 style=" display : none" id="productId"><?= $product['id'] ?></h1>
<div class="swiper-container productImageContainer">
<div class="swiper-wrapper productImageWrapper">
<?php
foreach ($images as $image) {
?>
<div class="swiper-slide productImageSlide">
<div class="productImage">
<img src=<?php echo "data:image/jpeg;base64," . base64_encode($image['image']) ?> alt="">
</div>
</div>
<?php
}
?>
</div>
<div class="swiper-button-next productImageNext"></div>
<div class="swiper-button-prev productImagePrev"></div>
<div class="swiper-pagination productImagePagination"></div>
</div>
<div class="productDetails">
<h1><?= $product['name'] ?></h1>
<p>
<?= $product['description'] ?>
</p>
<h2><?php echo "Prix: " . $product['price'] ?> Dt</h2>
<?php if ($product['quantity'] == 0) { ?>
<h4 style="color:red; letter-spacing:2px"> Le stock est épuisé </h4>
<?php } else if ($product['quantity'] <= 3) { ?>
<h4 style="color:red; letter-spacing:2px"> Il ne reste que <? $product['quantity'] ?> eléments !! </h4>
<?php } ?>
<?php $wishProductRep = new WishProductRepository();
$wish = $wishProductRep->findOneBy(array('productId' => $product['id'], 'userId' => $_SESSION['user']));
if ($wish) {
?>
<span class="wishedProduct"><i class="fas fa-heart"></i>
<h4>Wished</h4>
</span>
<?php
} else { ?>
<span class="wishedProduct"><i class="far fa-heart"></i>
<h4>Add to Wishlist</h4>
</span>
<?php
}
?>
<?php
$cartRep = new CartRepository();
$check = $cartRep->findOneBy(array('userId' => $_SESSION['user'], 'productId' => $product['id']));
?>
<span class="shopped"><i class="fas fa-shopping-cart"></i>
<h4><?php if ($check){echo $check['quantity'];} else{
echo '1';
} ?></h4>
<span>
<i class="fas fa-plus addCart"></i>
<i class="fas fa-minus removeCart"></i>
</span>
</span>
<span class="shop"><i class="fas fa-shopping-cart"></i>
<h4>Add to cart</h4>
</span>
<?php if($check){?>
<span id="shop" style="display: none;"><?php if ($check) {
echo $check['quantity'];
} ?></span>
<?php } else {?>
<span id="shop" style="display: none;">buy</span>
<?php } ?>
</div>
</div>
<div class="sendPost"></div>
<?php include_once 'assets/scripts.php' ?>
<?php include_once 'footer.php' ?>
<script src="js/product.js"></script>
<script src="js/main.js"></script>
<script type="js/scrollUpBtn.js"></script>
<script src="js/testnav.js"></script>
</body>
</html>