<?php chdir("../../database"); require_once "storeFrontend.php"; if (isset($_GET["productId"]) and isset($_GET["userId"])) { $productId = intval($_GET["productId"]); $userId = intval($_GET["userId"]); if (!favoriteExists($userId, $productId)) { setFavorite($userId, $productId); } echo json_encode(array("result" => "ok")); } else { echo json_encode(array("result" => "missingParams")); }
// Product $id = intval($_GET["id"]); $product = getProduct($id); if ($product["filename"] != 'imageurl') { $product["file"] = "../../files/" . $product["file"]; } $price = $product["price"] * (1 + $vat); $comments = getCommentsOfProduct($id); $isLoggedIn = false; $isFavorite = false; $isSubscribed = false; $smarty->assign('userPermission', 'guest'); if (isset($_SESSION['storesLogin'][$storeId]['userId'])) { $isLoggedIn = true; $userInfo = $_SESSION['storesLogin'][$storeId]['userId']; $isFavorite = favoriteExists($userInfo, $id); $isSubscribed = subscriptionExists($userInfo, $id); if (isset($userInfo)) { $userInfo = getAccount($userInfo); $userPermission = getAccountPermission($userInfo["id"]); $userPermission = $userPermission["name"]; } $smarty->assign('userInfo', $userInfo); $smarty->assign('userPermission', $userPermission); } $smarty->assign('isSubscribed', $isSubscribed); $smarty->assign('isLoggedIn', $isLoggedIn); /* END -- Get store data */ $storeName = getStoreName($domain); $smarty->assign('title', $storeName . " View product"); $smarty->assign('logoPath', $logoPath);