*/ session_start(); if (!isset($_SESSION['profile'])) { header('Location: /index.html'); exit(0); } else { // Если пользователь является заказчиком, ему доступна данная операция if ($_SESSION['profile']['type'] == 0) { $order = null; if (array_key_exists('order', $_SERVER)) { $orderId = filter_var($_SERVER['order'], FILTER_VALIDATE_INT); if ($orderId !== false) { includeModule('order'); // Атомарно отмечаем заказ удаленным if (lock_lock($orderId, 2, 1)) { if (order_delete($orderId, $_SESSION['profile']['user_id'])) { // Если удалось удалить заказ, прогреваем кеш для поиска заказов соответсвующим образом includeModule('cache'); cache_delete($orderId); lock_unlock($orderId); return ['completed' => true]; } else { lock_unlock($orderId); } } else { return ['error' => 'order locked']; } } } return ['error' => 'order not found']; } else {
default: // Do nothing as this actions requires us to stay in the // cart page to review details for the order } } else { if (isset($_POST['address'])) { // Here the cart has been submitted either for being an offer or has been // placed as an order $is_offer = isset($_POST['offer-state']) && $_POST['offer-state'] == 'true'; // We need to check if it is order and it // is coming from an existing offer then // we remove the offer to tbe replaced later // with the newly saved order if (!$is_offer && $Cart->isFromOffer()) { $from_offer_id = $Cart->getOfferId(); order_delete($from_offer_id); } // Processing the offer to an order // Dealing with delivery addresses $requisition_uploaded = false; if (!$is_offer) { switch ($_POST['address']) { case 'alternative': $requisition_uploaded = true; // If we have selected an old alternative address // we do not care about the other fields if (trim($_POST['OLD_ALTERNATIVE_CONTACT']) != '') { $dest_address = $_POST['OLD_ALTERNATIVE_CONTACT']; break; } // Add the address to the list of the alternative addresses