Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс

This commit is contained in:
jimagie committed 2026-10-22 19:28:52 +05:00
commit bb7d8af290
469 files changed
+26426

No files matched your search

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
use Bitrix\Main\Context;
use Bitrix\Main\Localization\Loc;
use Jinove\Vinoteca\Checkout;
use Jinove\Vinoteca\Money;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
Loc::loadMessages(__FILE__);
class JinoveOrderDoneComponent extends CBitrixComponent
{
public function executeComponent(): array
{
global $APPLICATION;
$APPLICATION->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;
}
}