public static function OnSaleBeforeStatusOrderChange(\Bitrix\Main\Event $event) {
/** @var \Bitrix\Sale\Order $order */
$order = $event->getParameter("ENTITY");
/** @var \Bitrix\Sale\Order $STATUS_ID */
$STATUS_ID = $order->getField("STATUS_ID");
/** @var $paymentCollection \Bitrix\Sale\PaymentCollection */
$paymentCollection = $order->getPaymentCollection();
$isPaid = $paymentCollection->isPaid();
if($STATUS_ID === 'PA' && $isPaid === true) {
$error = new \Bitrix\Main\Error("Заказ уже оплачен.");
$resultError = \Bitrix\Sale\ResultError::create($error);
return $event->addResult(
new \Bitrix\Main\EventResult(
\Bitrix\Main\EventResult::ERROR, $resultError, 'sale'
)
);
}
}
if($order->getField('STATUS_ID') == "F" && (MakeTimeStamp($order->getField('DATE_STATUS'), "DD.MM.YYYY HH:MI:SS")+120>time())){
retun false;
}