47 lines
2.4 KiB
PHP
47 lines
2.4 KiB
PHP
<?php
|
||
ini_set( 'display_errors', 1 );
|
||
|
||
switch( @$_POST['act'] ) {
|
||
case 'change-kolvo':
|
||
$session_id = ( $_SESSION['user_id'] ) ? $_SESSION['user_id'] : session_id();
|
||
\DB::set( "UPDATE `cart` SET `kolvo`=? WHERE `id`=? AND `user_id`=?", array( $_POST['kolvo'], $_POST['id'], $session_id ) ) ;
|
||
$res=\core::getCart();
|
||
echo $res['summ'];
|
||
break;
|
||
|
||
case 'del-from-cart':
|
||
$session_id = ( $_SESSION['user_id'] ) ? $_SESSION['user_id'] : session_id();
|
||
\DB::set( "DELETE FROM `cart` WHERE `id`=? AND `user_id`=?", array( $_POST['id'], $session_id ) ) ;
|
||
$res=\core::getCart();
|
||
echo $res['summ'];
|
||
break;
|
||
|
||
|
||
/* ----------------------------------------------------------------------
|
||
06.03.2023
|
||
Простое оформление заказа на зарегистрированного физ лица
|
||
---------------------------------------------------------------------- */
|
||
case 'zakazFz':
|
||
if (!$_SESSION['user_id'])die("403");
|
||
//Создаем заказ
|
||
$insert_id=\DB::add("INSERT INTO `orders` (`user_id`, `status`, `t`) VALUES (?, ?, ?)", array($_SESSION['user_id'], 0, time()));
|
||
//обновляем данные в корзине
|
||
\DB::set("UPDATE `cart` SET `order`=? WHERE `user_id`=? AND `order` IS NULL", array($insert_id, $_SESSION['user_id']));
|
||
break;
|
||
/* ----------------------------------------------------------------------
|
||
11.03.2023
|
||
Простое оформление заказа на НЕ зарегистрированного физ лица
|
||
---------------------------------------------------------------------- */
|
||
case 'zakazFzAnonim':
|
||
$user=\core::checkMe();
|
||
if ( $db['type'] == 'mysql' ) \DB::alterTable( "ALTER TABLE `orders` ADD `email` varchar(254) COLLATE 'utf8_general_ci' NULL" );
|
||
if ( $db['type']=='sqlite3' ) \DB::alterTable( "ALTER TABLE `orders` ADD `email` TEXT" );
|
||
//Создаем заказ
|
||
$insert_id=\DB::add("INSERT INTO `orders` (`user_id`, `status`, `t`, `fio`, `tel`, `email`) VALUES (?, ?, ?, ?, ?, ?)", array($user, 0, time(), $_POST['fio'], $_POST['tel'], $_POST['email'] ));
|
||
//обновляем данные в корзине
|
||
\DB::set("UPDATE `cart` SET `order`=? WHERE `user_id`=? AND `order` IS NULL", array($insert_id, $user));
|
||
break;
|
||
default:
|
||
|
||
}
|
||
?>
|