// 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);
$smarty->assign('title', $storeName . " Search results");
$smarty->assign('logoPath', $logoPath);
$smarty->assign('categories', $categories);
$smarty->assign('products', $products);
$smarty->assign('storeDomain', $domain);
$smarty->assign('storeId', $storeId);
$smarty->assign('vat', $vat);
$smarty->display('store/home.tpl');
<?php

chdir("../../common");
require_once "init.php";
chdir("../database");
require_once "storeAccount.php";
if (isset($_GET["orderId"])) {
    $orderId = intval($_GET["orderId"]);
    $userId = getOrderUserId($orderId);
    $user = get_UserById($userId);
    $address = $user["address"];
    $storeId = getUserStoreID($userId);
    if (isset($_SESSION['storesLogin'][$storeId]['userId'])) {
        $permission = getAccountPermission($_SESSION['storesLogin'][$storeId]['userId']);
        $permission = $permission["name"];
        if ($_SESSION['storesLogin'][$storeId]['userId'] == $userId or $permission == "merchant") {
            $items = getOrderItens($orderId);
            $smarty->assign("items", $items);
            $invoice = getOrderInvoice($orderId);
            $order = getOrder($orderId);
            $paid = $order["paid"];
            $smarty->assign("invoice", $invoice);
            $smarty->assign("order", $order);
            $smarty->assign("paid", $paid);
            $smarty->assign("address", $address);
            $smarty->display('store/invoice.tpl');
        }
    }
}