Ejemplo n.º 1
0
    }
    return $elem;
}
/* BEGIN -- Get store data */
$domain = $_GET["store"];
$storeId = getStoreId($domain);
// Logo
$logoPath = getStoreLogo($domain);
// Categories
$categories = getCategories($storeId);
// Products
$searchTerm = $_GET["terms"];
$products = searchOnStore($storeId, $searchTerm, 30);
$products = array_map("updatePath", $products);
// Vat
$vat_oux = getStoreById($storeId);
$vat = $vat_oux[0]["vat"];
//loged in user
$smarty->assign('userPermission', 'guest');
if (isset($_SESSION['storesLogin'][$storeId]['userId'])) {
    $userInfo = $_SESSION['storesLogin'][$storeId]['userId'];
    if (isset($userInfo)) {
        $userInfo = getAccount($userInfo);
        $userPermission = getAccountPermission($userInfo["id"]);
        $userPermission = $userPermission["name"];
    }
    $smarty->assign('userInfo', $userInfo);
    $smarty->assign('userPermission', $userPermission);
}
/* END -- Get store data */
$storeName = getStoreName($domain);
Ejemplo n.º 2
0
chdir("../../common");
require_once "init.php";
chdir("../database");
require_once "storeFrontend.php";
// Get data
$storeId = intval($_GET["storeId"]);
$userId = $_SESSION['storesLogin'][$storeId]['userId'];
$address = $_GET["address"];
setUserAddress($userId, $address);
$cart = $_SESSION['storesLogin'][$storeId]['cart'];
// Create order
$orderId = newOrder($userId);
$total = 0;
foreach ($cart as $item) {
    $productId = $item["id"];
    $quantity = $item["qt"];
    $baseCost = getProduct($productId);
    $baseCost = $baseCost["price"];
    $total += $quantity * $baseCost;
    addProductToOrder($orderId, $productId, $quantity, $baseCost);
}
// Create an invoice
$code = substr(str_shuffle(md5(time())), 0, 10);
$store = getStoreById($storeId);
$domain = $store[0]["domain"];
$vat = $store[0]["vat"];
$total *= 1 + $vat;
$id = createInvoice($code, $total, $vat, $orderId);
// Clear cart
$_SESSION['storesLogin'][$storeId]['cart'] = array();
header("Location: ../../pages/store/invoice.php?orderId=" . $orderId);