Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventcompatibility.php
1<?php
2
4
7
8Main\Localization\Loc::loadMessages(__FILE__);
9
11{
12 // Events old kernel, which will be called in a new kernel
13 const EVENT_COMPATIBILITY_ON_ORDER_PAID = "OnSalePayOrder";
14 const EVENT_COMPATIBILITY_ON_BEFORE_ORDER_DELETE = "OnBeforeOrderDelete";
15 const EVENT_COMPATIBILITY_ON_ORDER_DELETED = "OnOrderDelete";
16 const EVENT_COMPATIBILITY_ON_SHIPMENT_DELIVER = "OnSaleDeliveryOrder";
17
18 const EVENT_COMPATIBILITY_ON_ORDER_UPDATE = "OnOrderUpdate";
19
20 const EVENT_COMPATIBILITY_ON_BEFORE_ORDER_ADD = "OnBeforeOrderAdd";
21 const EVENT_COMPATIBILITY_ON_BEFORE_ORDER_UPDATE = "OnBeforeOrderUpdate";
22
23 const EVENT_COMPATIBILITY_ON_ORDER_SAVE = "OnOrderSave";
25
28
31
32 const EVENT_COMPATIBILITY_ON_BEFORE_ORDER_CANCELED = "OnSaleBeforeCancelOrder";
33 const EVENT_COMPATIBILITY_ON_ORDER_CANCELED = "OnSaleCancelOrder";
34
35 const EVENT_COMPATIBILITY_ON_TRACKING_NUMBER_CHANGE = "OnTrackingNumberChange";
36
37 const EVENT_COMPATIBILITY_ON_BEFORE_ORDER_STATUS_CHANGE = "OnSaleBeforeStatusOrder";
38 const EVENT_COMPATIBILITY_ON_ORDER_STATUS_CHANGE = "OnSaleStatusOrder";
39
40 const EVENT_COMPATIBILITY_ORDER_STATUS_SEND_EMAIL = "OnOrderStatusSendEmail";
41 const EVENT_COMPATIBILITY_ORDER_STATUS_EMAIL = "OnSaleStatusEMail";
43
44 const EVENT_COMPATIBILITY_ON_ORDER_NEW_SEND_EMAIL = "OnOrderNewSendEmail";
46
47 const EVENT_COMPATIBILITY_ON_ORDER_DELIVER_SEND_EMAIL = "OnOrderDeliverSendEmail";
49
50 const EVENT_COMPATIBILITY_ON_ORDER_PAID_SEND_EMAIL = "OnOrderPaySendEmail";
51
52 const EVENT_COMPATIBILITY_ON_ORDER_CANCEL_SEND_EMAIL = "OnOrderCancelSendEmail";
54
55 const EVENT_COMPATIBILITY_ON_BEFORE_BASKET_DELETE = "OnBeforeBasketDelete";
56 const EVENT_COMPATIBILITY_ON_BASKET_DELETED = "OnBasketDelete";
57
58// const EVENT_COMPATIBILITY_ON_BASKET_ = "OnSaleCancelOrder";
59
60
61 protected static $disableMailSend = false;
62
63 protected static $disableEvent = false;
64
65
70 public static function getEventListUsed($event)
71 {
72 return GetModuleEvents("sale", $event, true);
73 }
74
80 public static function onSalePayOrder(Main\Event $event)
81 {
82 if (static::$disableEvent === true)
83 {
84 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
85 }
86
87 $parameters = $event->getParameters();
88
90 $order = $parameters['ENTITY'];
91 if (!$order instanceof Sale\Order)
92 {
93 return new Main\EventResult(
94 Main\EventResult::ERROR,
95 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_PAY_WRONG_ORDER'),
96 'sale'
97 );
98 }
99
100 $id = $order->getId();
101 $value = $order->getField('PAYED');
102
103 static::setDisableEvent(true);
104 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_PAID, true) as $oldEvent)
105 {
106 ExecuteModuleEventEx($oldEvent, array($id, $value));
107 }
108 static::setDisableEvent(false);
109
110 if ($value == "Y")
111 {
112 if (Main\Loader::includeModule("statistic"))
113 {
114 \CStatEvent::AddByEvents("eStore", "order_paid", $id, "", $order->getField("STAT_GID"), $order->getPrice(), $order->getCurrency());
115 }
116 }
117 else
118 {
119 if (Main\Loader::includeModule("statistic"))
120 {
121 \CStatEvent::AddByEvents("eStore", "order_chargeback", $id, "", $order->getField("STAT_GID"), $order->getPrice(), $order->getCurrency(), "Y");
122 }
123 }
124
125 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
126 }
127
133 public static function onSaleOrderPaidSendMail(Main\Event $event)
134 {
135 if (static::$disableEvent === true)
136 {
137 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
138 }
139
140 $parameters = $event->getParameters();
141
143 $order = $parameters['ENTITY'];
144 if (!$order instanceof Sale\Order)
145 {
146 return new Main\EventResult(
147 Main\EventResult::ERROR,
148 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_PAY_SEND_EMAIL_WRONG_ORDER'),
149 'sale'
150 );
151 }
152
153 $value = $order->getField('PAYED');
154
155 if ($value == "Y")
156 {
157 $registry = Sale\Registry::getInstance($order::getRegistryType());
158
160 $notifyClassName = $registry->getNotifyClassName();
161 $notifyClassName::sendOrderPaid($order);
162 }
163 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
164 }
165
171 public static function onSaleOrderCancelSendEmail(Main\Event $event)
172 {
173 if (static::$disableEvent === true)
174 {
175 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
176 }
177
178 if (static::$disableMailSend === true)
179 {
180 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
181 }
182
183 $parameters = $event->getParameters();
184
186 $order = $parameters['ENTITY'];
187 if (!$order instanceof Sale\Order)
188 {
189 return new Main\EventResult(
190 Main\EventResult::ERROR,
191 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_CANCEL_SEND_EMAIL_WRONG_ORDER'),
192 'sale'
193 );
194 }
195
196 $id = $order->getId();
197 $value = $order->getField('CANCELED');
198
199 if ($value == "Y")
200 {
201 $registry = Sale\Registry::getInstance($order::getRegistryType());
202
204 $notifyClassName = $registry->getNotifyClassName();
205 $notifyClassName::sendOrderCancel($order);
206
207 if (Main\Loader::includeModule("statistic"))
208 {
209 \CStatEvent::AddByEvents("eStore", "order_cancel", $id, "", $order->getField("STAT_GID"));
210 }
211
212 $GLOBALS['SALE_ORDER_CANCEL_SEND'][$id] = true;
213
214 }
215 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
216 }
217
218
224 public static function onOrderNewSendEmail(Main\Event $event)
225 {
226 if (static::$disableEvent === true)
227 {
228 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
229 }
230
231 if (static::$disableMailSend === true)
232 {
233 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
234 }
235
236 $parameters = $event->getParameters();
237
239 $order = $parameters['ENTITY'];
240 $isNew = $parameters['IS_NEW'];
241
242 if (!$order instanceof Sale\Order)
243 {
244 return new Main\EventResult(
245 Main\EventResult::ERROR,
246 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_NEW_SEND_EMAIL_WRONG_ORDER'),
247 'sale'
248 );
249 }
250
251 $id = $order->getId();
252
253 if (!$isNew)
254 {
255 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
256 }
257
258 $registry = Sale\Registry::getInstance($order::getRegistryType());
259
261 $notifyClassName = $registry->getNotifyClassName();
262 $notifyClassName::sendOrderNew($order);
263
264 $GLOBALS['SALE_NEW_ORDER_SEND'][$id] = true;
265
266 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
267 }
268
269
270
275 public static function onBeforeOrderDelete(Main\Event $event)
276 {
277 if (static::$disableEvent === true)
278 {
279 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
280 }
281
282 $parameters = $event->getParameters();
283
285 $order = $parameters['ENTITY'];
286 if (!$order instanceof Sale\Order)
287 {
288 return new Main\EventResult(
289 Main\EventResult::ERROR,
290 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_BEFORE_ORDER_DELETE_WRONG_ORDER'),
291 'sale'
292 );
293 }
294
295 $id = $order->getId();
296
297 static::setDisableEvent(true);
298 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_DELETE, true) as $oldEvent)
299 {
300 if (ExecuteModuleEventEx($oldEvent, array($id)) === false)
301 {
302 return new Main\EventResult(
303 Main\EventResult::SUCCESS,
304 false,
305 'sale');
306 }
307 }
308 static::setDisableEvent(false);
309
310 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
311 }
312
313
318 public static function onOrderDelete(Main\Event $event)
319 {
320 if (static::$disableEvent === true)
321 {
322 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
323 }
324
325 $parameters = $event->getParameters();
326
328 $order = $parameters['ENTITY'];
329 if (!$order instanceof Sale\Order)
330 {
331 return new Main\EventResult(
332 Main\EventResult::ERROR,
333 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_DELETE_WRONG_ORDER'),
334 'sale'
335 );
336 }
337
338 $deleted = $parameters['VALUE'];
339 $id = $order->getId();
340
341 static::setDisableEvent(true);
342 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_DELETED, true) as $oldEvent)
343 {
344 ExecuteModuleEventEx($oldEvent, array($id, $deleted));
345 }
346 static::setDisableEvent(false);
347
348 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
349 }
350
357 public static function onSaleDeliveryOrder(Main\Event $event)
358 {
359 if (static::$disableEvent === true)
360 {
361 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
362 }
363
364 $parameters = $event->getParameters();
365
367 $shipment = $parameters['ENTITY'];
368 if (!$shipment instanceof Sale\Shipment)
369 {
370 return new Main\EventResult(
371 Main\EventResult::ERROR,
372 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_SHIPMENT'), 'SALE_EVENT_COMPATIBILITY_DELIVER_ORDER_WRONG_SHIPMENT'),
373 'sale'
374 );
375 }
376
378 if (!$shipmentCollection = $shipment->getCollection())
379 {
380 throw new Main\ObjectNotFoundException('Entity "ShipmentCollection" not found');
381 }
382
384 if (!$order = $shipmentCollection->getOrder())
385 {
386 throw new Main\ObjectNotFoundException('Entity "Order" not found');
387 }
388
389 $id = $order->getId();
390
391 static::setDisableEvent(true);
392 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_SHIPMENT_DELIVER, true) as $oldEvent)
393 {
394 ExecuteModuleEventEx($oldEvent, array($id, $shipment->getField('ALLOW_DELIVERY')));
395 }
396 static::setDisableEvent(false);
397
398 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
399 }
400
401
406 public static function onOrderSave(Main\Event $event)
407 {
408 if (static::$disableEvent === true)
409 {
410 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
411 }
412
413 $parameters = $event->getParameters();
414
416 $order = $parameters['ENTITY'];
417 $oldValues = $parameters['VALUES'];
418 if (!$order instanceof Sale\Order)
419 {
420 return new Main\EventResult(
421 Main\EventResult::ERROR,
422 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_SAVE_WRONG_ORDER'),
423 'sale'
424 );
425 }
426
427 $isNew = $order->isNew();
428 $id = $order->getId();
429
430 $fields = null;
431 $orderFields = array();
432
434 $resultOrderFields = OrderCompatibility::getOrderFields($order);
435 if ($resultOrderFields->isSuccess())
436 {
437 if ($orderFieldsResultData = $resultOrderFields->getData())
438 {
439 if (!empty($orderFieldsResultData['FIELDS']) && is_array($orderFieldsResultData['FIELDS']))
440 {
441 $fields = $orderFieldsResultData['FIELDS'];
442 }
443 if (!empty($orderFieldsResultData['ORDER_FIELDS']) && is_array($orderFieldsResultData['ORDER_FIELDS']))
444 {
445 $orderFields = $orderFieldsResultData['ORDER_FIELDS'];
446 }
447 }
448 }
449
450 static::setDisableEvent(true);
451 if ($isNew)
452 {
453 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_ADD, true) as $oldEvent)
454 {
455 ExecuteModuleEventEx($oldEvent, array($id, $orderFields));
456 }
457 }
458 else
459 {
460 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_UPDATE, true) as $oldEvent)
461 {
462 ExecuteModuleEventEx($oldEvent, array($id, $orderFields));
463 }
464 }
465 static::setDisableEvent(false);
466
467 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
468 }
469
474 public static function onOrderSaved(Main\Event $event)
475 {
476 if (static::$disableEvent === true)
477 {
478 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
479 }
480
481 $parameters = $event->getParameters();
482
484 $order = $parameters['ENTITY'];
485 $oldValues = $parameters['VALUES'];
486 if (!$order instanceof Sale\Order)
487 {
488 return new Main\EventResult(
489 Main\EventResult::ERROR,
490 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_SAVED_WRONG_ORDER'),
491 'sale'
492 );
493 }
494
495 $isNew = $parameters['IS_NEW'];
496 $id = $order->getId();
497
498 $fields = null;
499 $orderFields = null;
500
502 $resultOrderFields = OrderCompatibility::getOrderFields($order);
503 if ($resultOrderFields->isSuccess())
504 {
505 if ($orderFieldsResultData = $resultOrderFields->getData())
506 {
507 if (!empty($orderFieldsResultData['FIELDS']) && is_array($orderFieldsResultData['FIELDS']))
508 {
509 $fields = $orderFieldsResultData['FIELDS'];
510 }
511 if (!empty($orderFieldsResultData['ORDER_FIELDS']) && is_array($orderFieldsResultData['ORDER_FIELDS']))
512 {
513 $orderFields = $orderFieldsResultData['ORDER_FIELDS'];
514 }
515 }
516 }
517
518 static::setDisableEvent(true);
519 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_SAVE, true) as $oldEvent)
520 {
521 ExecuteModuleEventEx($oldEvent, array($id, $fields, $orderFields, $isNew));
522 }
523 static::setDisableEvent(false);
524
525 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
526 }
527
532 public static function onOrderAdd(Main\Event $event)
533 {
534 if (static::$disableEvent === true)
535 {
536 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
537 }
538
539 $parameters = $event->getParameters();
540
542 $order = $parameters['ENTITY'];
543 $isNew = $parameters['IS_NEW'];
544 if (!$isNew)
545 {
546 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
547 }
548
549 if (!$order instanceof Sale\Order)
550 {
551 return new Main\EventResult(
552 Main\EventResult::ERROR,
553 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_ADD_WRONG_ORDER'),
554 'sale'
555 );
556 }
557
558 $id = $order->getId();
559
560 $fields = null;
561 $orderFields = null;
562
564 $resultOrderFields = OrderCompatibility::getOrderFields($order);
565 if ($resultOrderFields->isSuccess())
566 {
567 if ($orderFieldsResultData = $resultOrderFields->getData())
568 {
569 if (!empty($orderFieldsResultData['ORDER_FIELDS']) && is_array($orderFieldsResultData['ORDER_FIELDS']))
570 {
571 $orderFields = $orderFieldsResultData['ORDER_FIELDS'];
572 }
573 }
574 }
575
576 static::setDisableEvent(true);
577 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_ADD, true) as $oldEvent)
578 {
579 ExecuteModuleEventEx($oldEvent, array($id, $orderFields));
580 }
581 static::setDisableEvent(false);
582
583 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
584 }
589 public static function onOrderBeforeSaved(Main\Event $event)
590 {
591 global $APPLICATION;
592
593 if (static::$disableEvent === true)
594 {
595 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
596 }
597
598
599 $parameters = $event->getParameters();
600
602 $order = $parameters['ENTITY'];
603
604 if (!$order instanceof Sale\Order)
605 {
606 return new Main\EventResult(
607 Main\EventResult::ERROR,
608 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_BEFORE_SAVED_WRONG_ORDER'),
609 'sale'
610 );
611 }
612
613 $id = $order->getId();
614
615 $fields = null;
616 $orderFields = null;
617
619 $resultOrderFields = OrderCompatibility::getOrderFields($order);
620 if ($resultOrderFields->isSuccess())
621 {
622 if ($orderFieldsResultData = $resultOrderFields->getData())
623 {
624 if (!empty($orderFieldsResultData['ORDER_FIELDS']) && is_array($orderFieldsResultData['ORDER_FIELDS']))
625 {
626 $orderFields = $orderFieldsResultData['ORDER_FIELDS'];
627 }
628 }
629 }
630
631 $currentOrderFields = $orderFields;
632
633 if ($order->isNew())
634 {
635 static::setDisableEvent(true);
636 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_ADD, true) as $oldEvent)
637 {
638 if (ExecuteModuleEventEx($oldEvent, array(&$orderFields)) === false)
639 {
640 if ($ex = $APPLICATION->GetException())
641 {
642 return new Main\EventResult(
643 Main\EventResult::ERROR,
644 new Sale\ResultError($ex->GetString(), $ex->GetID()),
645 'sale'
646 );
647 }
648
649 }
650 }
651
652 static::setDisableEvent(false);
653
655
656 foreach ($orderFields as $orderFieldName => $orderFieldValue)
657 {
658 if (in_array($orderFieldName, $allowFields)
659 && (array_key_exists($orderFieldName, $currentOrderFields) && $orderFieldValue != $currentOrderFields[$orderFieldName]))
660 {
662 $order->setFieldNoDemand($orderFieldName, $orderFieldValue);
663 }
664 }
665 }
666 else
667 {
668 static::setDisableEvent(true);
669 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_UPDATE, true) as $oldEvent)
670 {
671 if (ExecuteModuleEventEx($oldEvent, array($id, $orderFields)) === false)
672 {
673 $error = null;
674 if ($ex = $APPLICATION->GetException())
675 {
676 $error = new Sale\ResultError($ex->GetString(), $ex->GetID());
677 }
678
679 return new Main\EventResult(
680 Main\EventResult::ERROR,
681 $error,
682 'sale'
683 );
684 }
685 }
686 static::setDisableEvent(false);
687 }
688
689 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
690 }
691
692
697 public static function onSaleBeforeCancelOrder(Main\Event $event)
698 {
699 if (static::$disableEvent === true)
700 {
701 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
702 }
703
704 $parameters = $event->getParameters();
705
707 $order = $parameters['ENTITY'];
708 if (!$order instanceof Sale\Order)
709 {
710 return new Main\EventResult(
711 Main\EventResult::ERROR,
712 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_BEFORE_ORDER_DELETE_WRONG_ORDER'),
713 'sale'
714 );
715 }
716
717 $id = $order->getId();
718 $value = $order->getField('CANCELED');;
719
720 static::setDisableEvent(true);
721 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_CANCELED, true) as $oldEvent)
722 {
723 if (ExecuteModuleEventEx($oldEvent, array($id, $value)) === false)
724 {
725 return new Main\EventResult(
726 Main\EventResult::SUCCESS,
727 false,
728 'sale');
729 }
730 }
731 static::setDisableEvent(false);
732
733 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
734 }
735
736
741 public static function onSaleCancelOrder(Main\Event $event)
742 {
743 if (static::$disableEvent === true)
744 {
745 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
746 }
747
748 $parameters = $event->getParameters();
749
751 $order = $parameters['ENTITY'];
752 if (!$order instanceof Sale\Order)
753 {
754 return new Main\EventResult(
755 Main\EventResult::ERROR,
756 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_DELETE_WRONG_ORDER'),
757 'sale'
758 );
759 }
760
761 $canceled = $order->getField('CANCELED');
762 $id = $order->getId();
763 $description = $order->getField('REASON_CANCELED');
764
765 static::setDisableEvent(true);
766 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_CANCELED, true) as $oldEvent)
767 {
768 ExecuteModuleEventEx($oldEvent, array($id, $canceled, $description));
769 $order->setField('REASON_CANCELED', $description);
770 }
771 static::setDisableEvent(false);
772
773 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
774 }
775
782 public static function onBasketItemBeforeChange(Main\Event $event)
783 {
784 if (static::$disableEvent === true)
785 {
786 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
787 }
788
789 $parameters = $event->getParameters();
790
792 $basketItem = $parameters['ENTITY'];
793 $isNew = $parameters['IS_NEW'];
794 $oldValues = $parameters['VALUES'];
795
796 if (!$basketItem instanceof Sale\BasketItem)
797 {
798 return new Main\EventResult(
799 Main\EventResult::ERROR,
800 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_BASKET'), 'SALE_EVENT_COMPATIBILITY_BASKET_ITEM_BEFORE_CHANGE_WRONG_BASKET'),
801 'sale'
802 );
803 }
804
805 $currentBasketFields = BasketCompatibility::convertBasketItemToArray($basketItem);
806
807 $basketFields = array();
808
809 if ($isNew)
810 {
811 $basketFields = $currentBasketFields;
812 }
813 else
814 {
815 if (!empty($oldValues) && is_array($oldValues))
816 {
817 foreach ($oldValues as $oldValueKey => $oldValueData)
818 {
819 if (array_key_exists($oldValueKey, $currentBasketFields))
820 {
821 $basketFields[$oldValueKey] = $currentBasketFields[$oldValueKey];
822 }
823 }
824 }
825 }
826
827 if (array_key_exists('QUANTITY', $oldValues) && ($currentBasketFields['QUANTITY'] - $oldValues['QUANTITY']) > 0)
828 {
829 if (empty($basketFields['ID']) && !empty($currentBasketFields['ID']))
830 {
831 $basketFields['ID'] = $currentBasketFields['ID'];
832 }
833
834 $basketFields['QUANTITY'] = $currentBasketFields['QUANTITY'] - $oldValues['QUANTITY'];
835
836 static::setDisableEvent(true);
837 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_BASKET_ITEM_ADD, true) as $oldEvent)
838 {
839 ExecuteModuleEventEx($oldEvent, array(&$basketFields));
840 }
841 static::setDisableEvent(false);
842
843 $basketFields['QUANTITY'] = $oldValues['QUANTITY'] + $basketFields['QUANTITY'];
844 }
845
846 if (empty($basketFields) && !empty($oldValues) && is_array($oldValues))
847 {
848 foreach ($oldValues as $oldValueKey => $oldValueData)
849 {
850 if (array_key_exists($oldValueKey, $currentBasketFields))
851 {
852 $basketFields[$oldValueKey] = $currentBasketFields[$oldValueKey];
853 }
854 }
855 }
856
857 if (!$isNew)
858 {
859 static::setDisableEvent(true);
860 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_BASKET_ITEM_UPDATE, true) as $oldEvent)
861 {
862 ExecuteModuleEventEx($oldEvent, array($basketItem->getId(), &$basketFields));
863 }
864 static::setDisableEvent(false);
865 }
866
867
868 foreach ($currentBasketFields as $key => $value)
869 {
870 if (isset($basketFields[$key]) && !is_array($value) && $basketFields[$key] != $value)
871 {
872 $basketItem->setFieldNoDemand($key, $basketFields[$key]);
873 }
874 }
875
876 if (!empty($basketFields['PROPS']) && is_array($basketFields['PROPS']))
877 {
878 $propIndexList = array();
880 if (!$basketPropertyCollection = $basketItem->getPropertyCollection())
881 {
882 throw new Main\ObjectNotFoundException('Entity "BasketPropertiesCollection" not found');
883 }
884
885 $propDiffByName = false;
886
887 if (!empty($currentBasketFields['PROPS']) && is_array($currentBasketFields['PROPS']))
888 {
889 foreach ($currentBasketFields['PROPS'] as $propData)
890 {
891 $propCode = $propData["CODE"];
892 if (empty($propData["CODE"]))
893 {
894 $propCode = $propData["NAME"];
895 $propDiffByName = true;
896 }
897
898 $propIndexList[$propCode] = $propData;
899 }
900 }
901
902 foreach ($basketFields['PROPS'] as $propData)
903 {
904 $propCode = $propData["CODE"];
905 if (empty($propData["CODE"]) || $propDiffByName)
906 $propCode = $propData["NAME"];
907
908 if (isset($propIndexList[$propCode]))
909 {
910 $propOldData = $propIndexList[$propCode];
911 if ($propData['SORT'] != $propOldData['SORT'] || $propData['VALUE'] != $propOldData['VALUE'])
912 {
914 if ($basketPropertyItem = $basketPropertyCollection->getPropertyItemByValue($propIndexList[$propCode]))
915 {
916 $basketPropertyItem->setFieldsNoDemand($propData);
917 }
918 }
919 }
920 else
921 {
922 if ($basketPropertyItem = $basketPropertyCollection->createItem())
923 {
924 $basketPropertyItem->setFieldsNoDemand($propData);
925 }
926 }
927
928 }
929 }
930
931
932
933 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
934 }
935
941 public static function onBasketItemChange(Main\Event $event)
942 {
943 if (static::$disableEvent === true)
944 {
945 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
946 }
947
948 $parameters = $event->getParameters();
949
951 $basketItem = $parameters['ENTITY'];
952 $isNew = $parameters['IS_NEW'] ?? false;
953 $oldValues = $parameters['VALUES'];
954 if (!$basketItem instanceof Sale\BasketItem)
955 {
956 return new Main\EventResult(
957 Main\EventResult::ERROR,
958 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_BASKET'), 'SALE_EVENT_COMPATIBILITY_BASKET_ITEM_CHANGE_WRONG_BASKET'),
959 'sale'
960 );
961 }
962
963 $basketFields = BasketCompatibility::convertBasketItemToArray($basketItem);
964
965 static::setDisableEvent(true);
966 if (!$isNew)
967 {
968 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BASKET_ITEM_UPDATE, true) as $oldEvent)
969 {
970 ExecuteModuleEventEx($oldEvent, array($basketItem->getId(), $basketFields));
971 }
972 }
973
974 if (array_key_exists('QUANTITY', $oldValues) && ($basketFields['QUANTITY'] - $oldValues['QUANTITY']) > 0)
975 {
976 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BASKET_ITEM_ADD, true) as $oldEvent)
977 {
978 ExecuteModuleEventEx($oldEvent, Array($basketItem->getId(), $basketFields));
979 }
980 }
981
982 static::setDisableEvent(false);
983
984 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
985 }
986
993 public static function onShipmentTrackingNumberChange(Main\Event $event)
994 {
995 if (static::$disableEvent === true)
996 {
997 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
998 }
999
1000 $parameters = $event->getParameters();
1001
1003 $shipment = $parameters['ENTITY'];
1004 $oldValues = $parameters['VALUES'];
1005 if (!$shipment instanceof Sale\Shipment)
1006 {
1007 return new Main\EventResult(
1008 Main\EventResult::ERROR,
1009 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_SHIPMENT'), 'SALE_EVENT_COMPATIBILITY_SHIPMENT_TRACKING_NUMBER_CHANGE_WRONG_SHIPMENT'),
1010 'sale'
1011 );
1012 }
1013
1015 if (!$shipmentCollection = $shipment->getCollection())
1016 {
1017 throw new Main\ObjectNotFoundException('Entity "ShipmentCollection" not found');
1018 }
1019
1021 if (!$order = $shipmentCollection->getOrder())
1022 {
1023 throw new Main\ObjectNotFoundException('Entity "Order" not found');
1024 }
1025
1026 static::setDisableEvent(true);
1027 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_TRACKING_NUMBER_CHANGE, true) as $oldEvent)
1028 {
1029 ExecuteModuleEventEx($oldEvent, Array($order->getId(), $shipment->getField('TRACKING_NUMBER')));
1030 }
1031 static::setDisableEvent(false);
1032
1033 if (array_key_exists('TRACKING_NUMBER', $oldValues) && strval($shipment->getField('TRACKING_NUMBER')) != ''
1034 && $oldValues["TRACKING_NUMBER"] != $shipment->getField('TRACKING_NUMBER'))
1035 {
1036
1037 $registry = Sale\Registry::getInstance($shipment::getRegistryType());
1038
1040 $notifyClassName = $registry->getNotifyClassName();
1041 $notifyClassName::sendShipmentTrackingNumberChange($shipment);
1042 }
1043
1044 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1045 }
1046
1053 public static function onShipmentAllowDelivery(Main\Event $event)
1054 {
1055 if (static::$disableEvent === true)
1056 {
1057 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1058 }
1059
1060 $parameters = $event->getParameters();
1061
1063 $shipment = $parameters['ENTITY'];
1064 $oldValues = $parameters['VALUES'];
1065 if (!$shipment instanceof Sale\Shipment)
1066 {
1067 return new Main\EventResult(
1068 Main\EventResult::ERROR,
1069 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_SHIPMENT'), 'SALE_EVENT_COMPATIBILITY_SHIPMENT_ALLOW_DELIVERY_WRONG_SHIPMENT'),
1070 'sale'
1071 );
1072 }
1073
1075 if (!$shipmentCollection = $shipment->getCollection())
1076 {
1077 throw new Main\ObjectNotFoundException('Entity "ShipmentCollection" not found');
1078 }
1079
1081 if (!$order = $shipmentCollection->getOrder())
1082 {
1083 throw new Main\ObjectNotFoundException('Entity "Order" not found');
1084 }
1085
1086 if ($shipmentCollection->isAllowDelivery() && array_key_exists('ALLOW_DELIVERY', $oldValues) && strval($shipment->getField('ALLOW_DELIVERY')) != ''
1087 && $oldValues["ALLOW_DELIVERY"] != $shipment->getField('ALLOW_DELIVERY'))
1088 {
1089
1090 $registry = Sale\Registry::getInstance($shipment::getRegistryType());
1091
1093 $notifyClassName = $registry->getNotifyClassName();
1094 $notifyClassName::sendShipmentAllowDelivery($shipment);
1095 }
1096
1097 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1098 }
1099
1106 public static function onSaleStatusOrderChange(Main\Event $event)
1107 {
1108 if (static::$disableEvent === true)
1109 {
1110 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1111 }
1112
1113 $parameters = $event->getParameters();
1114
1116 $order = $parameters['ENTITY'];
1117 $value = $parameters['VALUE'];
1118 $oldValue = $parameters['OLD_VALUE'];
1119 if (!$order instanceof Sale\Order)
1120 {
1121 return new Main\EventResult(
1122 Main\EventResult::ERROR,
1123 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_STATUS_CHANGE_WRONG_ORDER'),
1124 'sale'
1125 );
1126 }
1127
1128 static::setDisableEvent(true);
1129 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_STATUS_CHANGE, true) as $oldEvent)
1130 {
1131 ExecuteModuleEventEx($oldEvent, array($order->getId(), $value));
1132 }
1133 static::setDisableEvent(false);
1134
1135 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1136 }
1137
1144 public static function onSaleOrderStatusChangeSendEmail(Main\Event $event)
1145 {
1146 if (static::$disableEvent === true)
1147 {
1148 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1149 }
1150
1151 $parameters = $event->getParameters();
1152
1154 $order = $parameters['ENTITY'];
1155 $value = $parameters['VALUE'];
1156 $oldValue = $parameters['OLD_VALUE'];
1157 if (!$order instanceof Sale\Order)
1158 {
1159 return new Main\EventResult(
1160 Main\EventResult::ERROR,
1161 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_STATUS_CHANGE_SEND_EMAIL_WRONG_ORDER'),
1162 'sale'
1163 );
1164 }
1165
1166 $registry = Sale\Registry::getInstance($order::getRegistryType());
1167
1169 $notifyClassName = $registry->getNotifyClassName();
1170 $notifyClassName::sendOrderStatusChange($order);
1171
1172 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1173 }
1174
1182 public static function onCallOrderNewSendEmail($id, $eventName, $fields)
1183 {
1184 if (static::$disableMailSend === true)
1185 {
1186 return true;
1187 }
1188
1189 if (!empty($GLOBALS['SALE_NEW_ORDER_SEND'][$id]))
1190 {
1191 return false;
1192 }
1193
1194 return true;
1195 }
1196
1204 public static function onCallOrderCancelSendEmail($id, $eventName, $fields)
1205 {
1206 if (static::$disableMailSend === true)
1207 {
1208 return true;
1209 }
1210
1211 if (!empty($GLOBALS['SALE_ORDER_CANCEL_SEND'][$id]))
1212 {
1213 return false;
1214 }
1215
1216 return true;
1217 }
1218
1225 public static function onSaleBeforeStatusOrderChange(Main\Event $event)
1226 {
1227 if (static::$disableEvent === true)
1228 {
1229 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1230 }
1231
1232 $parameters = $event->getParameters();
1233
1235 $order = $parameters['ENTITY'];
1236 $value = $parameters['VALUE'];
1237 $oldValue = $parameters['OLD_VALUE'];
1238 if (!$order instanceof Sale\Order)
1239 {
1240 return new Main\EventResult(
1241 Main\EventResult::ERROR,
1242 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_BEFORE_ORDER_STATUS_CHANGE_WRONG_ORDER'),
1243 'sale'
1244 );
1245 }
1246
1247 static::setDisableEvent(true);
1248 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_STATUS_CHANGE, true) as $oldEvent)
1249 {
1250 if (ExecuteModuleEventEx($oldEvent, array($order->getId(), $value)) === false)
1251 {
1252 static::setDisableEvent(false);
1253 return new Main\EventResult( Main\EventResult::ERROR, null, 'sale');
1254 }
1255 }
1256
1257 static::setDisableEvent(false);
1258
1259 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1260 }
1261
1262
1267 public static function onBeforeBasketDelete(Main\Event $event)
1268 {
1269 if (static::$disableEvent === true)
1270 {
1271 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1272 }
1273
1274 $parameters = $event->getParameters();
1275
1277 $basketItem = $parameters['ENTITY'];
1278 if (!$basketItem instanceof Sale\BasketItem)
1279 {
1280 return new Main\EventResult(
1281 Main\EventResult::ERROR,
1282 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_BASKET_ITEM'), 'SALE_EVENT_COMPATIBILITY_BEFORE_BASKET_ITEM_DELETE_WRONG_BASKET_ITEM'),
1283 'sale'
1284 );
1285 }
1286
1287 $id = $basketItem->getId();
1288
1289 static::setDisableEvent(true);
1290 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_BASKET_DELETE, true) as $oldEvent)
1291 {
1292 if (ExecuteModuleEventEx($oldEvent, array($id)) === false)
1293 {
1294 return new Main\EventResult(
1295 Main\EventResult::SUCCESS,
1296 false,
1297 'sale');
1298 }
1299 }
1300 static::setDisableEvent(false);
1301
1302 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1303 }
1304
1305
1310 public static function onBasketDelete(Main\Event $event)
1311 {
1312 if (static::$disableEvent === true)
1313 {
1314 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1315 }
1316
1317 $parameters = $event->getParameters();
1318
1320 $values = $parameters['VALUES'];
1321 if (empty($values) || !is_array($values))
1322 {
1323 return new Main\EventResult(
1324 Main\EventResult::ERROR,
1325 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_VALUES'), 'SALE_EVENT_COMPATIBILITY_BASKET_ITEM_DELETE_WRONG_VALUES'),
1326 'sale'
1327 );
1328 }
1329
1330 if (empty($values['ID']))
1331 {
1332 return new Main\EventResult(
1333 Main\EventResult::ERROR,
1334 new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ID'), 'SALE_EVENT_COMPATIBILITY_BASKET_ITEM_DELETE_WRONG_ID'),
1335 'sale'
1336 );
1337 }
1338
1339 $id = $values['ID'];
1340
1341 static::setDisableEvent(true);
1342 foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BASKET_DELETED, true) as $oldEvent)
1343 {
1344 ExecuteModuleEventEx($oldEvent, array($id));
1345 }
1346 static::setDisableEvent(false);
1347
1348 return new Main\EventResult( Main\EventResult::SUCCESS, null, 'sale');
1349 }
1350
1354 public static function setDisableMailSend($value)
1355 {
1356 static::$disableMailSend = ($value === true || $value == "Y");
1357 }
1358
1362 protected static function setDisableEvent($value)
1363 {
1364 static::$disableEvent = ($value === true);
1365 }
1366
1370 protected static function isDisableEvent()
1371 {
1372 return static::$disableEvent;
1373 }
1374
1378 public static function registerEvents()
1379 {
1380 $eventManager = Main\EventManager::getInstance();
1381
1382 $eventManager->registerEventHandler('sale', 'OnSaleOrderPaid', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSalePayOrder');
1383
1384 $eventManager->registerEventHandler('sale', 'OnSaleOrderBeforeSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderBeforeSaved');
1385
1386 $eventManager->registerEventHandler('sale', 'OnSaleBeforeOrderDelete', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBeforeOrderDelete');
1387
1388 $eventManager->registerEventHandler('sale', 'OnSaleOrderDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderDelete');
1389
1390 $eventManager->registerEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleDeliveryOrder');
1391
1392 $eventManager->registerEventHandler('sale', 'OnSaleBeforeOrderCanceled', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleBeforeCancelOrder');
1393
1394 $eventManager->registerEventHandler('sale', 'OnSaleOrderCanceled', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleCancelOrder');
1395
1396 $eventManager->registerEventHandler('sale', 'OnSaleOrderPaidSendMail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderPaidSendMail', 500);
1397
1398 $eventManager->registerEventHandler('sale', 'OnSaleOrderCancelSendEmail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderCancelSendEmail', 500);
1399
1400 $eventManager->registerEventHandler('sale', 'OnSaleOrderEntitySaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderSave');
1401
1402 $eventManager->registerEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderSaved');
1403
1404 $eventManager->registerEventHandler('sale', 'OnSaleBasketItemBeforeSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBasketItemBeforeChange');
1405
1406 $eventManager->registerEventHandler('sale', 'OnSaleBasketItemEntitySaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBasketItemChange');
1407
1408 $eventManager->registerEventHandler('sale', 'OnShipmentTrackingNumberChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onShipmentTrackingNumberChange');
1409
1410 $eventManager->registerEventHandler('sale', 'OnSaleBeforeStatusOrderChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleBeforeStatusOrderChange');
1411
1412 $eventManager->registerEventHandler('sale', 'OnSaleStatusOrderChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleStatusOrderChange');
1413
1414 $eventManager->registerEventHandler('sale', 'OnSaleOrderStatusChangeSendEmail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderStatusChangeSendEmail', 500);
1415
1416 $eventManager->registerEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderNewSendEmail', 500);
1417
1418 RegisterModuleDependences("sale", "OnOrderNewSendEmail", "sale", "\\Bitrix\\Sale\\Compatible\\EventCompatibility", "onCallOrderNewSendEmail", 500);
1419
1420 $eventManager->registerEventHandler('sale', 'OnBeforeSaleBasketItemEntityDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'OnBeforeBasketDelete');
1421
1422 $eventManager->registerEventHandler('sale', 'OnSaleBasketItemDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'OnBasketDelete');
1423
1424 $eventManager->registerEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onShipmentAllowDelivery');
1425
1426 RegisterModuleDependences("sale", "OnOrderCancelSendEmail", "sale", "\\Bitrix\\Sale\\Compatible\\EventCompatibility", "onCallOrderCancelSendEmail", 500);
1427
1428 $eventManager->registerEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleOrderAddEvent');
1429
1430 $eventManager->registerEventHandler('sale', 'OnSaleStatusOrderChange', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleStatusOrderHandlerEvent');
1431
1432 $eventManager->registerEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleDeliveryOrderHandlerEvent');
1433
1434 $eventManager->registerEventHandler('sale', 'OnShipmentDeducted', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleDeductOrderHandlerEvent');
1435
1436 $eventManager->registerEventHandler('sale', 'OnSaleOrderCanceled', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleCancelOrderHandlerEvent');
1437
1438 $eventManager->registerEventHandler('sale', 'OnSaleOrderPaid', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSalePayOrderHandlerEvent');
1439
1440 UnRegisterModuleDependences("sale", "OnBasketOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleOrderAdd", 100);
1441 UnRegisterModuleDependences("sale", "OnSaleStatusOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleStatusOrderHandler", 100);
1442 UnRegisterModuleDependences("sale", "OnSaleDeliveryOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeliveryOrderHandler", 100);
1443 UnRegisterModuleDependences("sale", "OnSaleDeductOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeductOrderHandler", 100);
1444 UnRegisterModuleDependences("sale", "OnSaleCancelOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleCancelOrderHandler", 100);
1445 UnRegisterModuleDependences("sale", "OnSalePayOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSalePayOrderHandler", 100);
1446
1447 }
1448
1452 public static function unRegisterEvents()
1453 {
1454 $eventManager = Main\EventManager::getInstance();
1455
1456 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderPaid', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSalePayOrder');
1457
1458 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderBeforeSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderBeforeSaved');
1459
1460 $eventManager->unRegisterEventHandler('sale', 'OnSaleBeforeOrderDelete', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBeforeOrderDelete');
1461
1462 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderDelete');
1463
1464 $eventManager->unRegisterEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleDeliveryOrder');
1465
1466 $eventManager->unRegisterEventHandler('sale', 'OnSaleBeforeOrderCanceled', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleBeforeCancelOrder');
1467
1468 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderCanceled', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleCancelOrder');
1469
1470 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderPaidSendMail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderPaidSendMail');
1471
1472 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderCancelSendEmail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderCancelSendEmail');
1473
1474 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderEntitySaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderSave');
1475
1476 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderSaved');
1477
1478 $eventManager->unRegisterEventHandler('sale', 'OnSaleBasketItemBeforeSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBasketItemBeforeChange');
1479
1480 $eventManager->unRegisterEventHandler('sale', 'OnSaleBasketItemEntitySaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onBasketItemChange');
1481
1482 $eventManager->unRegisterEventHandler('sale', 'OnShipmentTrackingNumberChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onShipmentTrackingNumberChange');
1483
1484 $eventManager->unRegisterEventHandler('sale', 'OnSaleBeforeStatusOrderChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleBeforeStatusOrderChange');
1485
1486 $eventManager->unRegisterEventHandler('sale', 'OnSaleStatusOrderChange', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleStatusOrderChange');
1487
1488 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderStatusChangeSendEmail', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onSaleOrderStatusChangeSendEmail');
1489
1490 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onOrderNewSendEmail');
1491
1492 UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", "sale", "\\Bitrix\\Sale\\Compatible\\EventCompatibility", "onCallOrderNewSendEmail");
1493
1494 $eventManager->unRegisterEventHandler('sale', 'OnBeforeSaleBasketItemEntityDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'OnBeforeBasketDelete');
1495
1496 $eventManager->unRegisterEventHandler('sale', 'OnSaleBasketItemDeleted', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'OnBasketDelete');
1497
1498 $eventManager->unRegisterEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Compatible\EventCompatibility', 'onShipmentAllowDelivery');
1499
1500 UnRegisterModuleDependences("sale", "OnOrderCancelSendEmail", "sale", "\\Bitrix\\Sale\\Compatible\\EventCompatibility", "onCallOrderCancelSendEmail");
1501
1502 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderSaved', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleOrderAddEvent');
1503
1504 $eventManager->unRegisterEventHandler('sale', 'OnSaleStatusOrderChange', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleStatusOrderHandlerEvent');
1505
1506 $eventManager->unRegisterEventHandler('sale', 'OnShipmentAllowDelivery', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleDeliveryOrderHandlerEvent');
1507
1508 $eventManager->unRegisterEventHandler('sale', 'OnShipmentDeducted', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleDeductOrderHandlerEvent');
1509
1510 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderCanceled', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSaleCancelOrderHandlerEvent');
1511
1512 $eventManager->unRegisterEventHandler('sale', 'OnSaleOrderPaid', 'sale', '\Bitrix\Sale\Product2ProductTable', 'onSalePayOrderHandlerEvent');
1513
1514 RegisterModuleDependences("sale", "OnBasketOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleOrderAdd", 100);
1515 RegisterModuleDependences("sale", "OnSaleStatusOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleStatusOrderHandler", 100);
1516 RegisterModuleDependences("sale", "OnSaleDeliveryOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeliveryOrderHandler", 100);
1517 RegisterModuleDependences("sale", "OnSaleDeductOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeductOrderHandler", 100);
1518 RegisterModuleDependences("sale", "OnSaleCancelOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleCancelOrderHandler", 100);
1519 RegisterModuleDependences("sale", "OnSalePayOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSalePayOrderHandler", 100);
1520
1521 }
1522
1523}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static onCallOrderCancelSendEmail($id, $eventName, $fields)
static onCallOrderNewSendEmail($id, $eventName, $fields)
$GLOBALS['____1444769544']
Definition license.php:1