-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewProduct.php
More file actions
55 lines (43 loc) · 1.55 KB
/
Copy pathViewProduct.php
File metadata and controls
55 lines (43 loc) · 1.55 KB
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
<?php
include_once('./functions.php');
if (!isset($_GET['ProductID']) || !($productID = $_GET['ProductID'])) {
include "./views/partials/head.php";
include "./views/Error.view.php";
die();
}
include('./views/partials/head.php');
include('./views/partials/navbar.php');
$heading = 'Product Details';
include('./views/partials/banner.php');
$cartString = isset($_COOKIE['ShoppingCart']) ? $_COOKIE['ShoppingCart'] : '';
$allowAddToCart = !$cartString || !stringContains($cartString, $productID);
$db = connectToDatabase();
$statement = $db->prepare("SELECT * FROM Products AS P INNER JOIN Brands AS B ON P.BrandID = B.BrandID WHERE P.ProductID = ? ;");
$statement->bindValue(1, $productID);
$statement->execute();
$data = $statement->fetch(PDO::FETCH_ASSOC);
$content = $allowAddToCart
? '
<form method="POST"
action="./AddToCart.php?ProductID=' . $productID . '"
class="ViewProduct-cart-form">
<div class="ViewProduct-qty-group">
<label for="quantity" class="ViewProduct-qty-label">Qty</label>
<input name="Quantity"
type="number"
id="quantity"
value="1"
min="1"
class="ViewProduct-qty-input">
</div>
<button name="BuyButton"
type="submit"
class="ViewProduct-add-btn">
Add to Cart
</button>
</form>'
: '
<div class="ViewProduct-added">
<i class="fa fa-check"> </i>In your cart
</div>';
include './views/ViewProduct.view.php';