public function __construct(Connection $connection, $name, $address, $email, $addition) { parent::__construct($connection, $name, $address, $email, $addition); $productsInCart = $_COOKIE['products']; $cost = 0; $this->order_id = parent::getCurrentId($connection); foreach ($productsInCart as $id => $value) { $product = Products::get($id, $connection); $cost += $product['price'] * $value; $insProd = $connection->prepare('INSERT INTO `ordersproducts` (`order_id`, `product_id`, `amount`) VALUES (:order_id, :product_id, :amount)'); $insProd->execute([":order_id" => $this->order_id, ":product_id" => $id, ":amount" => $value]); } parent::setPrice($connection, $cost, $this->order_id); }
<?php use Respect\Validation\Validator as v; include_once __DIR__ . '/templates/_header.php'; include_once __DIR__ . '/templates/_top_menu.php'; $flag = false; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; $order = \App\DB\Orders::getById($id, $connection); if (v::arr()->notEmpty()->validate($order)) { $flag = true; } } ?> <section> <div class="container"> <div class="row clearfix"> <!-- боковое меню --> <?php include_once '/templates/_menu.php'; ?> <div class="column column9"> <div class="catalog"> <!-- хлебные крошки --> <div class="breadcrumbs"> <a href="/">Магазин</a> <p>Просмотр заказа</p> </div> <div class="row orders clearfix"> <?php
include_once __DIR__ . '/templates/_top_menu.php'; ?> <section> <div class="container"> <div class="row clearfix"> <!-- боковое меню --> <?php include_once '/templates/_menu.php'; ?> <div class="column column9"> <div class="catalog"> <!-- хлебные крошки --> <div class="breadcrumbs"> <a href="/">Магазин</a> <p>Список заказов</p> </div> <div class="row orders clearfix"> <p>Чтобы увидеть информацию по заказу, щелкните по ID или времени создания</p> <?php $orders = \App\DB\Orders::getIdAndDate($connection); include_once '/templates/_order-list-pagination.php'; ?> </div> </div> </div> </div> </div> </section> <?php include_once __DIR__ . '/templates/_footer.php';
<?php include_once __DIR__ . '/templates/_header.php'; include_once __DIR__ . '/templates/_top_menu.php'; $error_mess = ""; if (empty($_POST) || $_POST['ord_fio'] == '' || $_POST['ord_addr'] == '' || $_POST['ord_email'] == '') { if (!empty($_POST)) { if ($_POST['ord_fio'] == '') { $error_mess .= "Не заполнено поле \"ФИО\"<br/>"; } if ($_POST['ord_addr'] == '') { $error_mess .= "Не заполнено поле \"Адрес\"<br/>"; } if ($_POST['ord_email'] == '') { $error_mess .= "Не заполнено поле \"E-mail\"<br/>"; } if (mb_strlen($error_mess) > 1) { echo "<p>{$error_mess}</p>"; unset($error_mess); } } include_once __DIR__ . '/templates/_order_form.php'; include_once __DIR__ . '/templates/_footer.php'; } else { $ord = \App\DB\Orders::setOrder($connection); echo "<div class='tx_res'>Ваш заказ успешно оформлен!</div>"; ?> <script>delCookie('products')</script>; <?php } include_once __DIR__ . '/templates/_footer.php';