-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproducts.php
27 lines (26 loc) · 880 Bytes
/
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
<?php
session_start();
include_once('autoload.php');
/*gestion wishlist*/
$wishProductRep = new WishProductRepository();
$wished = $_POST['wish'];
if ($wished) {
$wishProductRep->insert(array('userId' => $_SESSION['user'], 'productId' => $_POST['product']));
} else {
$wishProductRep->deleteTwo('userId', $_SESSION['user'], 'productId', $_POST['product']);
}
/*gestion cart */
$product = $_POST['product'];
$user = $_SESSION['user'];
$quantity = $_POST['shopping'];
$cartRep = new CartRepository();
$check = $cartRep->findOneBy(array('userId' => $user, 'productId' => $product));
if ($check) {
if ($quantity) {
$cartRep->updateCart($product, $user, $quantity);
} else {
$cartRep->deleteTwo('productId', $product, 'userId', $user);
}
} else {
$cartRep->insert(array('userId' => $user, 'productId' => $product, 'quantity' => $quantity));
}