wunschliste.php modified that only products in database userFavorites are monitored. Problem with Wunschlisten Add button fixed. !!! Not possible yet: deleting things from wishlist !!!
This commit is contained in:
parent
73b7ff1baf
commit
1ad4d05473
@ -125,9 +125,8 @@ S
|
|||||||
.shop-left {
|
.shop-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 16px;
|
gap: 28px; /* vorher ~18px */
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-logo {
|
.shop-logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -152,12 +151,13 @@ S
|
|||||||
}
|
}
|
||||||
|
|
||||||
.shop-middle {
|
.shop-middle {
|
||||||
display: flex; /* statt column */
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 30px; /* Abstand zwischen Preis / Versand / Lager */
|
gap: 55px; /* vorher ~35px → jetzt deutlich mehr Abstand */
|
||||||
color: #cbd5e1;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
color: #cbd5e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-shipping {
|
.shop-shipping {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -184,6 +184,7 @@ S
|
|||||||
}
|
}
|
||||||
|
|
||||||
.shop-price {
|
.shop-price {
|
||||||
|
margin-left: auto;
|
||||||
font-size: 18px; /* kleiner als vorher */
|
font-size: 18px; /* kleiner als vorher */
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #4ade80;
|
color: #4ade80;
|
||||||
|
|||||||
BIN
assets/images/shopLogo/Dummie.png
Normal file
BIN
assets/images/shopLogo/Dummie.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@ -70,36 +70,67 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|||||||
|
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
$product = $result->fetch_assoc();
|
$product = $result->fetch_assoc();
|
||||||
|
|
||||||
|
$alreadyInWishlist = false;
|
||||||
|
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
|
||||||
|
$stmtCheck = mysqli_prepare(
|
||||||
|
$conn,
|
||||||
|
"SELECT 1 FROM userFavorites
|
||||||
|
WHERE userID = ? AND productID = ?
|
||||||
|
LIMIT 1"
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($stmtCheck) {
|
||||||
|
mysqli_stmt_bind_param(
|
||||||
|
$stmtCheck,
|
||||||
|
"ii",
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$productId
|
||||||
|
);
|
||||||
|
|
||||||
|
mysqli_stmt_execute($stmtCheck);
|
||||||
|
mysqli_stmt_store_result($stmtCheck);
|
||||||
|
|
||||||
|
if (mysqli_stmt_num_rows($stmtCheck) > 0) {
|
||||||
|
$alreadyInWishlist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysqli_stmt_close($stmtCheck);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$alreadyInWishlist = null;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$_SERVER['REQUEST_METHOD'] === 'POST' &&
|
$_SERVER['REQUEST_METHOD'] === 'POST' &&
|
||||||
isset($_POST['add_wishlist']) &&
|
isset($_POST['add_wishlist']) &&
|
||||||
isset($_SESSION['user_id'])
|
isset($_SESSION['user_id'])
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$userId = (int)$_SESSION['user_id'];
|
if (!$alreadyInWishlist) {
|
||||||
$productIdPost = (int)$_POST['product_id'];
|
|
||||||
|
|
||||||
if ($productIdPost > 0 && $alreadyInWishlist == null) {
|
|
||||||
|
|
||||||
$stmtFav = mysqli_prepare(
|
$stmtFav = mysqli_prepare(
|
||||||
$conn,
|
$conn,
|
||||||
"INSERT IGNORE INTO userFavorites (productID, userID) VALUES (?, ?)"
|
"INSERT INTO userFavorites (productID, userID) VALUES (?, ?)"
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($stmtFav) {
|
if ($stmtFav) {
|
||||||
mysqli_stmt_bind_param($stmtFav, 'ii', $productIdPost, $userId);
|
mysqli_stmt_bind_param(
|
||||||
|
$stmtFav,
|
||||||
|
'ii',
|
||||||
|
$productId,
|
||||||
|
$_SESSION['user_id']
|
||||||
|
);
|
||||||
|
|
||||||
mysqli_stmt_execute($stmtFav);
|
mysqli_stmt_execute($stmtFav);
|
||||||
mysqli_stmt_close($stmtFav);
|
mysqli_stmt_close($stmtFav);
|
||||||
|
|
||||||
$alreadyInWishlist = true;
|
$alreadyInWishlist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="product-wrapper">
|
<div class="product-wrapper">
|
||||||
@ -222,7 +253,7 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|||||||
|
|
||||||
<div class="shop-middle">
|
<div class="shop-middle">
|
||||||
<div class="shop-shipping">
|
<div class="shop-shipping">
|
||||||
Versand: <?= htmlspecialchars($shop['shippingCost']) ?> €
|
Versand: <?= htmlspecialchars($shop['shippingCost']) ?> €      
|
||||||
Lieferzeit: <?= htmlspecialchars($shop['shippingTime']) ?> Werktage
|
Lieferzeit: <?= htmlspecialchars($shop['shippingTime']) ?> Werktage
|
||||||
</div>
|
</div>
|
||||||
<div class="shop-stock <?= $shop['inStock'] ? 'in-stock' : 'out-stock' ?>">
|
<div class="shop-stock <?= $shop['inStock'] ? 'in-stock' : 'out-stock' ?>">
|
||||||
|
|||||||
@ -25,34 +25,20 @@ if (!$conn)
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$activeCategory = isset($_GET['category']) ? $_GET['category'] : 'all';
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
|
||||||
$categories = [
|
|
||||||
'iphone' => ['id' => 20, 'label' => 'iPhone'],
|
|
||||||
'ipad' => ['id' => 21, 'label' => 'iPad'],
|
|
||||||
'macbook' => ['id' => 22, 'label' => 'MacBook'],
|
|
||||||
'airpods' => ['id' => 23, 'label' => 'AirPods'],
|
|
||||||
'accessories' => ['id' => 24, 'label' => 'Accessories'],
|
|
||||||
];
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach ($categories as $key => $cat): ?>
|
|
||||||
|
|
||||||
<?php if ($activeCategory === 'all' || $activeCategory === $key): ?>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$stmt = $conn->prepare("
|
$stmt = $conn->prepare("
|
||||||
SELECT productID, model, description, imagePath
|
SELECT products.productID, products.model, products.description, products.imagePath
|
||||||
FROM products
|
FROM userFavorites INNER JOIN products ON userFavorites.productID = products.productID
|
||||||
WHERE categoryID = ?
|
WHERE userID = ?
|
||||||
");
|
");
|
||||||
|
|
||||||
$stmt->bind_param("i", $cat['id']); // i = integer
|
$stmt->bind_param("i", $_SESSION['user_id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
@ -60,7 +46,6 @@ $categories = [
|
|||||||
|
|
||||||
<?php if ($result->num_rows > 0): ?>
|
<?php if ($result->num_rows > 0): ?>
|
||||||
<section class="product-section">
|
<section class="product-section">
|
||||||
<h2><?= htmlspecialchars($cat['label']) ?></h2>
|
|
||||||
|
|
||||||
<div class="product-scroll">
|
<div class="product-scroll">
|
||||||
<?php while ($product = $result->fetch_assoc()): ?>
|
<?php while ($product = $result->fetch_assoc()): ?>
|
||||||
@ -82,10 +67,6 @@ $categories = [
|
|||||||
|
|
||||||
<?php $stmt->close(); ?>
|
<?php $stmt->close(); ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user