SetPageProperty("vino_alternates", "N"); $APPLICATION->SetPageProperty("vino_schema", "N"); $APPLICATION->SetPageProperty("robots", "noindex, nofollow"); $query = Context::getCurrent()->getRequest()->getQueryList()->toArray(); $order = Checkout::find((int)($query["id"] ?? 0), (string)($query["hash"] ?? "")); $state = "missing"; $data = []; if ($order !== null && !$order->isCanceled()) { $method = Checkout::methodOf($order); if ($method !== "cash" && ($query["cancel"] ?? "") !== "Y") { Checkout::finishPayment($order, $query); $order = \Bitrix\Sale\Order::load($order->getId()); } $payment = $order->getPaymentCollection()->current(); $state = $method !== "cash" ? ($payment !== null && $payment->isPaid() ? "paid" : "pending") : "cash"; $properties = []; foreach ($order->getPropertyCollection() as $property) { $properties[(string)$property->getField("CODE")] = (string)$property->getValue(); } $items = []; foreach ($order->getBasket() as $item) { $items[] = [ "name" => (string)$item->getField("NAME"), "quantity" => (int)$item->getQuantity(), "sum" => Money::format((float)$item->getFinalPrice(), (string)$item->getCurrency()), ]; } $data = [ "ID" => (int)$order->getId(), "HASH" => (string)$order->getHash(), "NUMBER" => (string)$order->getField("ACCOUNT_NUMBER"), "TOTAL" => Money::format((float)$order->getPrice(), (string)$order->getCurrency()), "NAME" => $properties["NAME"] ?? "", "PHONE" => $properties["PHONE"] ?? "", "EMAIL" => $properties["EMAIL"] ?? "", "METHOD" => $payment !== null ? (string)Loc::getMessage("VINO_PAY_" . strtoupper($method)) : "", "ITEMS" => $items, "CANCELLED" => ($query["cancel"] ?? "") === "Y", ]; } $title = (string)Loc::getMessage("VINO_DONE_TITLE_" . strtoupper($state)); $APPLICATION->SetTitle($title); $APPLICATION->SetPageProperty("title", $title . " | Vinoteca"); $APPLICATION->SetPageProperty("description", (string)Loc::getMessage("VINO_DONE_DESCRIPTION")); $this->arResult = ["STATE" => $state, "TITLE" => $title, "ORDER" => $data, "CATALOG_URL" => SITE_DIR . "catalog/", "AUTOPAY" => ($query["autopay"] ?? "") === "Y", "PAY_FAILED" => ($query["pay"] ?? "") === "failed"]; $this->includeComponentTemplate(); return $this->arResult; } }