示例#1
0
 public static function saveOrder()
 {
     $t = time();
     $timestamp = date("Y-m-d, H:i:s", $t);
     $narocil_id = OrdersDB::insert(["uporabnik_id" => $_SESSION["id"], "datum" => $timestamp]);
     foreach ($_SESSION["CART"] as $id => $value) {
         OrdersDB::insertOrderProduct(["kolicina" => $value, "narocilo_id" => $narocil_id, "izdelek_id" => $id]);
     }
     if (isset($_SESSION["CART"])) {
         unset($_SESSION["CART"]);
     }
     http_response_code(204);
 }
示例#2
0
 public static function saveOrder()
 {
     $action = filter_input(INPUT_POST, "do", FILTER_SANITIZE_SPECIAL_CHARS);
     if ($action == "order") {
         $t = time();
         $timestamp = date("Y-m-d, H:i:s", $t);
         $narocil_id = OrdersDB::insert(["uporabnik_id" => $_SESSION["id"], "datum" => $timestamp]);
         foreach ($_SESSION["CART"] as $id => $value) {
             OrdersDB::insertOrderProduct(["kolicina" => $value, "narocilo_id" => $narocil_id, "izdelek_id" => $id]);
         }
         if (isset($_SESSION["CART"])) {
             unset($_SESSION["CART"]);
         }
         ViewHelper::redirect(BASE_URL . "customer");
     } else {
         ViewHelper::redirect(BASE_URL . "customer/cart");
     }
 }