Skip to content

Instantly share code, notes, and snippets.

@EscApp2
Created April 17, 2024 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EscApp2/ee944eaf2fa27db5d06f7e59cb4ba3fd to your computer and use it in GitHub Desktop.
Save EscApp2/ee944eaf2fa27db5d06f7e59cb4ba3fd to your computer and use it in GitHub Desktop.
Stop add check, Stop Print Check For Empty Delivery Service
<?
$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('sale', '\Bitrix\Sale\Cashbox\Internals\CashboxCheck::OnBeforeAdd', 'StopPrintCheckForEmptyDeliveryService');
function StopPrintCheckForEmptyDeliveryService(\Bitrix\Main\Event $event){
$BITRIX_EMPTY_DELIVERY_ID = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
$arParameters = $event->getParameters();
$arFields = $arParameters['fields'];
if("sell" == $arFields['TYPE']){
if($arFields['ORDER_ID']){
$obOrder = SaleOrderSavedHelp::getOrder($arFields['ORDER_ID']);
$shipmentCollection = $obOrder->getShipmentCollection();
foreach($shipmentCollection as $obShipment){
$shipmentID = $obShipment->getId();
if($shipmentID == $arFields['SHIPMENT_ID']) {
$arDeliveryIds[] = $obShipment->getDeliveryId();
}
}
$arDeliveryIds = array_unique($arDeliveryIds);
if(in_array($BITRIX_EMPTY_DELIVERY_ID,$arDeliveryIds)){
$eventResult = new Bitrix\Main\Entity\EventResult();
$eventResult->addError( new \Bitrix\Sale\ResultError('Нельзя добавить чек к доставке "Без доставки"', 'CUSTOM_EVENT_HANDLER_FOR_EMPTY_DELIVERY'));
return $eventResult;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment