Пример #1
0
<h2>Корзина</h2>

<?php 
if (!isset($_SESSION['id_user'])) {
    echo "<p>*Требуется войти, чтобы совершить покупку</p>";
}
?>

<div>
<?php 
$cart_goods = Cart::getInstance()->getAllCookies();
if (!empty($cart_goods)) {
    echo "<a href='http://localhost/iba/cart/removeAll'>Очистить корзину</a><br><br>";
    $good = new Goods();
    foreach ($cart_goods as $key => $value) {
        $good->getGood($key);
        echo "<form action='" . PATHSITE . "/purchase/buy' method='post' oninput='cost.value=(price.valueAsNumber * count.valueAsNumber)'>";
        echo "<a href='" . PATHSITE . "/good/" . $key . "'>" . $good->name . "</a> ";
        echo "<input name='id' type='number' hidden='true' value='{$key}'>";
        echo "<input name='count' type='number' min='1' step='1' required='true' value={$value}> ";
        echo "<input name='price' type='number' hidden='true' value={$good->price}>";
        echo "<input name='cost' type='number' min='1' readonly='true' required='true' value={$good->price}> ";
        if (isset($_SESSION['id_user'])) {
            echo "<input name='submitButton' type='submit' value='Купить'>  ";
        }
        echo "<a href='" . PATHSITE . "/cart/remove?id={$key}'>Удалить</a><br>";
        echo "</form>";
    }
} else {
    echo "<p>Вы пока ничего не добавили</p>";
}
Пример #2
0
            $in_sale = 0;
        }
        if (isset($_POST['is_showed'])) {
            $is_showed = 1;
        } else {
            $is_showed = 0;
        }
        $id_category = 0;
        $good->saveData($_POST['name'], $_POST['price'], htmlspecialchars($_POST['review']), $_POST['size'], $_POST['color'], $img_link, $in_sale, $is_showed, $_POST['id_category']);
        header("Location: " . PATHSITE . "/admin-goods");
        break;
    case "remove":
        $good = new Goods();
        $good->deleteData("goods", $_POST['id_good']);
        header("Location: " . PATHSITE . "/admin-goods");
        break;
    case "update":
        $good = new Goods();
        $good->getGood($_POST['id_good']);
        if ($_FILES["img_link"]["name"] != '' & $_FILES["img_link"]["size"] < 1024 * 3 * 1024 & is_uploaded_file($_FILES["img_link"]["tmp_name"])) {
            move_uploaded_file($_FILES["img_link"]["tmp_name"], PATHSAVE . $_FILES["img_link"]["name"]);
            $img_link = $_FILES["img_link"]["name"];
        } else {
            $img_link = $good->img_link;
        }
        $good->updateGood($_POST['id_good'], $_POST['name'], $_POST['price'], htmlspecialchars($_POST['review']), $_POST['size'], $_POST['color'], $img_link, $_POST['in_sale'], $_POST['is_showed'], $_POST['id_category']);
        header("Location: " . $_SERVER['HTTP_REFERER']);
        break;
    default:
        break;
}
Пример #3
0
<?php

include_once "../models/purchase.php";
include_once "../models/goods.php";
$id_purchase = Purchase::getInstance()->buy();
Purchase::getInstance()->getPurchase($id_purchase);
$good = new Goods();
$good->getGood(Purchase::getInstance()->id_good);
$GLOBALS['title'] = "Покупка";
include_once "header.php";
?>

<p><b>Покупка успешно завершена!</b></p>
 
<?php 
if (Purchase::getInstance()->id_good != '') {
    echo "<p>Ваш номер заказа:" . $id_purchase;
    ?>
</p>
<p>Вы заказали
<?php 
    echo "<b>" . $good->name . ", " . Purchase::getInstance()->count . " шт<br></b>";
    echo "Сумма заказа: " . Purchase::getInstance()->cost . " руб.";
}
?>
</p>
<p>Чуть позднее с Вами свяжется наш специалист для уточнения времени доставки.</p>
<p>*по указанному Вами телефону в настройках.</p>

<a href="http://localhost/iba/cart">Вернуться к корзине</a>
Пример #4
0
<?php

include_once "../core/model.php";
include_once "../models/categories.php";
include_once "../models/goods.php";
include_once "../views/functions.php";
$id_good = getIdFromUrl();
$good = new Goods();
$good->getGood($id_good);
$GLOBALS['title'] = $good->name;
include_once "header.php";
echo "<a href=" . $_SERVER['HTTP_REFERER'] . ">Вернуться к просмотру</a>";
// or href="javascript:history.go(-1)"
echo "<br><label><b>Название:</b></label><br>";
echo "<p><b> {$good->name} </b></p>";
echo "<label><b>Цена:</b></label><br>";
echo "<p> {$good->price} </p>";
echo "<label><b>Размеры:</b></label><br>";
echo "<p> {$good->size} </p>";
echo "<label><b>Описание:</b></label><br>";
echo "<p> {$good->review} </p>";
if ($good->img_link != "") {
    ?>
 <img id="good_img" src="<?php 
    echo PATHSITE . "/img/" . $good->img_link;
    ?>
" width="300px" height="300px"><br>
<?php 
}
if ($good->in_sale == 1) {
    echo "<button><a href = '" . PATHSITE . "/cart/add?id={$good->id}&count=1'>Добавить в корзину</a></button>";