Last active
May 14, 2024 07:30
-
-
Save EscApp2/ee944eaf2fa27db5d06f7e59cb4ba3fd to your computer and use it in GitHub Desktop.
Stop add check, Stop Print Check For Empty Delivery Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$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; | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Не отправлять чек на 0 рублей | |
$eventManager = \Bitrix\Main\EventManager::getInstance(); | |
$eventManager->addEventHandler('sale', '\Bitrix\Sale\Cashbox\Internals\CashboxCheck::OnBeforeAdd', 'doNotSendZeroCheck'); | |
function doNotSendZeroCheck(\Bitrix\Main\Event $event){ | |
$arParameters = $event->getParameters(); | |
$arFields = $arParameters['fields']; | |
if("advancepayment" == $arFields['TYPE']){ | |
if(empty($arFields['SUM'])){ | |
$eventResult = new Bitrix\Main\Entity\EventResult(); | |
$eventResult->addError( new \Bitrix\Sale\ResultError( | |
'Нельзя добавить чек к оплате с ценой 0', | |
'CUSTOM_EVENT_HANDLER_FOR_EMPTY_PAYMENT')); | |
return $eventResult; | |
} | |
} | |
} | |
// удалить ошибку "Нельзя добавить чек к оплате с ценой 0" из админки | |
// every time on confirm page | |
AddEventHandler("sale", "OnSaleComponentOrderOneStepFinal", "OnSaleComponentOrderOneStepFinal_digift"); | |
function OnSaleComponentOrderOneStepFinal_digift($ORDER_ID, $arOrder, $arParams){ | |
if(digift_settings::isEnable()){ | |
\Bitrix\Main\Loader::includeModule('sale'); | |
if(is_numeric($ORDER_ID)){ | |
$obOrder = \Bitrix\Sale\Order::load($ORDER_ID); | |
$DIGIFT_CARD = SaleOrderSavedHelp::getPropertyD7($obOrder,'DIGIFT_CARD'); | |
if($DIGIFT_CARD){ | |
if( "Y" == $obOrder->getField('MARKED') | |
&& strpos( | |
$obOrder->getField('REASON_MARKED'), | |
"Нельзя добавить чек к оплате с ценой 0" | |
) !== false | |
){ | |
$obOrder->setField('MARKED',"N"); // не работает на событии OnSaleComponentOrderOneStepComplete | |
$obOrder->setField('REASON_MARKED',""); | |
//сохранить заказ | |
$obOrder->save(); | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment