Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
discountcompatibility.php
1<?php
3
8
9Loc::loadMessages(__FILE__);
10
12{
13 const MODE_CLIENT = 0x0001;
14 const MODE_MANAGER = 0x0002;
15 const MODE_ORDER = 0x0004;
16 const MODE_SYSTEM = 0x0008;
17 const MODE_EXTERNAL = 0x0010;
18 const MODE_DISABLED = 0x0020;
19
20 const ERROR_ID = 'BX_SALE_DISCOUNT_COMPATIBILITY';
21
22 protected static $init = false;
23 protected static $useMode = self::MODE_CLIENT;
24 protected static $errors = array();
25 protected static $config = array();
26 protected static $order = null;
27 protected static $discountUseMode = null;
28 protected static $basketBasePrice = array();
29 protected static $basketDiscountList = array();
30 protected static $basketItemsData = array();
31 protected static $discountResult = array();
32 protected static $discountsCache = array();
33 protected static $couponsCache = array();
34 protected static $previousOrderData = array();
35 protected static $currentOrderData = array();
36 protected static $compatibleSaleDiscountResult = array();
37 protected static $useCompatible = false;
38 protected static $shipmentOrder = null;
39 protected static $shipmentId = null;
40 protected static $basketCodes = array();
41 protected static $saved = false;
42 protected static $repeatSave = false;
43
50 public static function OnSaleBasketItemRefreshData(Main\Event $event)
51 {
52 if (static::isInited() && static::usedByClient())
53 {
54 $parameters = $event->getParameters();
56 $basketItem = $parameters['ENTITY'];
58 $values = $parameters['PREPARED_VALUES'];
59 unset($parameters);
60
61 if (
62 $basketItem instanceof Sale\BasketItem
63 && $basketItem->canBuy()
64 && !empty($values)
65 && is_array($values)
66 )
67 {
68 static::setBasketItemData($basketItem->getBasketCode(), $values);
69 }
70 unset($values, $basketItem);
71 }
72 return new Main\EventResult(Main\EventResult::SUCCESS, null, 'sale');
73 }
74
88 public static function initUseMode($mode = self::MODE_CLIENT, $config = array())
89 {
90 $adminSection = (defined('ADMIN_SECTION') && ADMIN_SECTION === true);
91 $mode = (int)$mode;
92 if (!is_array($config))
93 $config = array();
94
95 if ($adminSection)
96 {
97 self::$useMode = self::MODE_SYSTEM;
98 switch ($mode)
99 {
101 if (empty($config['SITE_ID']))
102 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_SITE_ABSENT');
103 elseif (empty($config['CURRENCY']))
104 $config['CURRENCY'] = Sale\Internals\SiteCurrencyTable::getCurrency($config['SITE_ID']);
105 if (empty($config['CURRENCY']))
106 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_CURRENCY_ABSENT');
107 if (empty(self::$errors))
108 {
109 self::$useMode = self::MODE_MANAGER;
110 $config['SALE_DISCOUNT_ONLY'] = (string)Main\Config\Option::get('sale', 'use_sale_discount_only');
111 self::$config = $config;
112 self::$discountUseMode = Sale\Discount::USE_MODE_FULL;
113 }
114 break;
115 case self::MODE_ORDER:
116 if (empty($config['ORDER_ID']))
117 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_ORDER_ID_ABSENT');
118 if (empty($config['SITE_ID']))
119 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_SITE_ABSENT');
120 if (empty($config['CURRENCY']))
121 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_CURRENCY_ABSENT');
122 if (empty(self::$errors))
123 {
124 self::$useMode = self::MODE_ORDER;
125 self::$order = $config['ORDER_ID'];
126 unset($config['ORDER_ID']);
127 self::$config = $config;
128 }
129 break;
131 break;
132 default:
133 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_BAD_MODE');
134 }
135 }
136 else
137 {
138 self::$useMode = self::MODE_SYSTEM;
139 switch ($mode)
140 {
142 self::$useMode = self::MODE_CLIENT;
143 if (empty($config['SITE_ID']))
144 $config['SITE_ID'] = SITE_ID;
145 if (empty($config['CURRENCY']))
146 $config['CURRENCY'] = Sale\Internals\SiteCurrencyTable::getSiteCurrency($config['SITE_ID']);
147 $config['SALE_DISCOUNT_ONLY'] = (string)Main\Config\Option::get('sale', 'use_sale_discount_only');
148 self::$config = $config;
149 self::$discountUseMode = Sale\Discount::USE_MODE_FULL;
150 break;
152 self::$useMode = self::MODE_EXTERNAL;
153 if (empty($config['SITE_ID']))
154 $config['SITE_ID'] = SITE_ID;
155 if (empty($config['CURRENCY']))
156 $config['CURRENCY'] = Sale\Internals\SiteCurrencyTable::getSiteCurrency($config['SITE_ID']);
157 $config['SALE_DISCOUNT_ONLY'] = (string)Main\Config\Option::get('sale', 'use_sale_discount_only');
158 self::$config = $config;
159 self::$discountUseMode = Sale\Discount::USE_MODE_FULL;
160 break;
162 break;
164 self::$useMode = self::MODE_DISABLED;
165 break;
166 default:
167 self::$errors[] = Loc::getMessage('BX_SALE_DCL_ERR_BAD_MODE');
168 break;
169 }
170 }
171 }
172
178 public static function getUseMode()
179 {
180 return self::$useMode;
181 }
182
188 public static function usedByClient()
189 {
190 return (self::$useMode == self::MODE_CLIENT);
191 }
192
198 public static function usedByManager()
199 {
200 return (self::$useMode == self::MODE_MANAGER || self::$useMode == self::MODE_ORDER);
201 }
202
209 public static function isSaved()
210 {
211 return self::$saved;
212 }
213
221 public static function setSaved($save)
222 {
223 if ($save !== true && $save !== false)
224 return;
225 self::$saved = $save;
226 }
227
234 public static function isRepeatSave()
235 {
236 return self::$repeatSave;
237 }
238
246 public static function setRepeatSave($repeat)
247 {
248 if ($repeat !== true && $repeat !== false)
249 return;
250 self::$repeatSave = $repeat;
251 }
252
258 public static function isSuccess()
259 {
260 return empty(self::$errors);
261 }
262
268 public static function getErrors()
269 {
270 return self::$errors;
271 }
272
278 public static function clearErrors()
279 {
280 self::$errors = array();
281 }
282
288 public static function getConfig()
289 {
290 return self::$config;
291 }
292
293
301 public static function setShipment($order, $shipment)
302 {
303 self::$shipmentOrder = $order;
304 self::$shipmentId = $shipment;
305 }
306
314 public static function init($mode = self::MODE_CLIENT, $config = array())
315 {
316 if (self::$init)
317 return;
320 if (!self::isSuccess())
321 return;
322 self::$basketBasePrice = array();
323 self::$basketDiscountList = array();
324 self::$basketItemsData = array();
325 self::$useCompatible = true;
326 Sale\OrderDiscountManager::setManagerConfig(self::$config);
327 self::$saved = false;
328 self::$repeatSave = false;
329 self::$init = true;
330 }
331
339 public static function reInit($mode = self::MODE_CLIENT, $config = array())
340 {
341 self::$init = false;
342 self::init($mode, $config);
343 }
344
350 public static function isInited()
351 {
352 return self::$init;
353 }
354
360 public static function isUsed()
361 {
363 }
364
372 public static function stopUsageCompatible()
373 {
374 if(self::$useCompatible)
375 {
376 self::$useCompatible = false;
377 }
378 }
379
386 public static function revertUsageCompatible()
387 {
388 if(self::$init && !self::$useCompatible)
389 {
390 self::$useCompatible = true;
391 }
392 }
393
402 public static function setBasketItemBasePrice($code, $price, $currency)
403 {
404 if (!self::$init)
405 self::init();
406 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
407 return;
409 self::$basketBasePrice[$code] = (
410 $currency == self::$config['CURRENCY']
411 ? $price
412 : \CCurrencyRates::convertCurrency($price, $currency, self::$config['CURRENCY'])
413 );
414 }
415
423 public static function setBasketBasePrice($basket)
424 {
425 if (!self::$init)
426 self::init();
427 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
428 return;
429 self::$basketBasePrice = array();
430 if (empty($basket) || !is_array($basket))
431 return;
432 foreach ($basket as $code => $basketItem)
433 {
435 self::$basketBasePrice[$code] = (
436 $basketItem['CURRENCY'] == self::$config['CURRENCY']
437 ? $basketItem['PRICE']
438 : \CCurrencyRates::convertCurrency($basketItem['PRICE'], $basketItem['CURRENCY'], self::$config['CURRENCY'])
439 );
440 }
441 unset($code, $basketItem);
442 }
443
450 public static function getBasketItemBasePrice($code)
451 {
452 if (!self::$init)
453 self::init();
454 return (isset(self::$basketBasePrice[$code]) ? self::$basketBasePrice[$code] : null);
455 }
456
464 public static function setBasketItemDiscounts($code, $discountList)
465 {
466 if (!self::$init)
467 self::init();
468 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
469 return;
470 if (self::$config['SALE_DISCOUNT_ONLY'] == 'Y')
471 return;
472 if (!is_array($discountList))
473 return;
474 self::$basketDiscountList[$code] = $discountList;
475 }
476
483 public static function getBasketItemDiscounts($code)
484 {
485 if (!self::$init)
486 self::init();
487 if (self::$config['SALE_DISCOUNT_ONLY'] == 'Y')
488 return null;
489 return (isset(self::$basketDiscountList[$code]) ? self::$basketDiscountList[$code] : null);
490 }
491
497 public static function setBasketItemData($code, $providerData)
498 {
499 if ($code == '' || empty($providerData) || !is_array($providerData))
500 return;
501 if (isset($providerData['CUSTOM_PRICE']) && $providerData['CUSTOM_PRICE'] == 'Y')
502 {
503 static::clearBasketItemData($code);
504 return;
505 }
506 if (isset($providerData['BASE_PRICE']) && isset($providerData['CURRENCY']))
507 static::setBasketItemBasePrice($code, $providerData['BASE_PRICE'], $providerData['CURRENCY']);
508 if (isset($providerData['DISCOUNT_LIST']))
509 {
510 if (!empty($providerData['DISCOUNT_LIST']) || isset(self::$basketDiscountList[$code]))
511 static::setBasketItemDiscounts($code, $providerData['DISCOUNT_LIST']);
512 }
513
514 $fields['PRICE'] = static::getBasketItemBasePrice($code);
515 if (empty($fields['PRICE']))
516 return;
517
518 self::$basketItemsData[$code] = $providerData;
519
520 $fields['DISCOUNT_PRICE'] = 0;
521 $fields['CURRENCY'] = self::$config['CURRENCY'];
522
523 if (self::$config['SALE_DISCOUNT_ONLY'] == 'Y')
524 return;
525 static::calculateBasketItemDiscount($code, $fields);
526 }
527
534 public static function clearBasketItemData($code)
535 {
536 if (isset(self::$basketBasePrice[$code]))
537 unset(self::$basketBasePrice[$code]);
538 if (isset(self::$basketDiscountList[$code]))
539 unset(self::$basketDiscountList[$code]);
540 if (isset(self::$discountResult['BASKET'][$code]))
541 unset(self::$discountResult['BASKET'][$code]);
542 if (isset(self::$basketItemsData[$code]))
543 unset(self::$basketItemsData[$code]);
544 }
545
551 public static function clearDiscountResult()
552 {
553 self::$discountResult = array(
554 'BASKET' => array(),
555 'BASKET_ROUND' => array(),
556 'ORDER' => array()
557 );
558 self::$compatibleSaleDiscountResult = array();
559 }
560
567 public static function fillBasketData(&$basket)
568 {
569 if (!self::$init)
570 self::init();
571 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
572 return;
573 if (empty($basket) || !is_array($basket))
574 return;
575 $publicMode = self::usedByClient();
576
577 $loadBasketProperties = array();
578 foreach ($basket as $basketCode => $basketItem)
579 {
580 $code = ($publicMode ? $basketItem['ID'] : $basketCode);
581 if (!isset($basketItem['DISCOUNT_PRICE']))
582 $basketItem['DISCOUNT_PRICE'] = 0;
583 if (!isset($basketItem['BASE_PRICE']))
584 {
585 $basketItem['BASE_PRICE'] = (isset(self::$basketBasePrice[$code])
586 ? self::$basketBasePrice[$code]
587 : $basketItem['PRICE'] + $basketItem['DISCOUNT_PRICE']
588 );
589 }
590 $checkProperties = true;
591 if (self::isCustomPrice($basketItem))
592 {
593 if (array_key_exists($code, self::$basketDiscountList))
594 unset(self::$basketDiscountList[$code]);
595 $checkProperties = false;
596 }
597 if (\CSaleBasketHelper::isSetItem($basketItem))
598 {
599 $basketItem['PRICE'] = $basketItem['BASE_PRICE'];
600 $basketItem['DISCOUNT_PRICE'] = 0;
601 $checkProperties = false;
602 }
603 if (isset(self::$basketItemsData[$code]))
604 {
605 if (isset(self::$basketItemsData[$code]['PRICE_TYPE_ID']))
606 $basketItem['PRICE_TYPE_ID'] = self::$basketItemsData[$code]['PRICE_TYPE_ID'];
607 }
608
609 if ($checkProperties)
610 {
611 if (!isset($basketItem['PROPERTIES']))
612 {
613 if (isset($basketItem['PROPS']))
614 $basketItem['PROPERTIES'] = $basketItem['PROPS'];
615 elseif (isset($basketItem['ID']))
616 {
617 $loadBasketProperties[$basketItem['ID']] = $basketCode;
618 $basketItem['PROPERTIES'] = array();
619 }
620 }
621 }
622 $basketItem['ACTION_APPLIED'] = 'N';
623 $basket[$basketCode] = $basketItem;
624 }
625
626 if (!empty($loadBasketProperties))
627 {
628 $iterator = Sale\BasketPropertiesCollection::getList(array(
629 'select' => array('*'),
630 'filter' => array('BASKET_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC')
631 ));
632 while ($row = $iterator->fetch())
633 {
634 $id = $row['ID'];
635 if (!isset($loadBasketProperties[$id]))
636 continue;
637 $basketCode = $loadBasketProperties[$id];
638 $basket[$basketCode]['PROPERTIES'][] = array(
639 'CODE' => ((string)$row['CODE'] != '' ? $row['CODE'] : $row['NAME']),
640 'ID' => $row['ID'],
641 'VALUE' => $row['VALUE'],
642 'SORT' => $row['SORT'],
643 'NAME' => $row['NAME']
644 );
645 }
646 unset($row, $iterator);
647 }
648 unset($loadBasketProperties);
649
650 unset($basketCode, $basketItem);
651 }
652
659 public static function calculateBasketDiscounts(&$basket)
660 {
661 if (!self::$init)
662 return false;
663 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
664 return false;
665 if (empty($basket) || !is_array($basket))
666 return false;
667 Sale\DiscountCouponsManager::clearApply();
668 if (self::$config['SALE_DISCOUNT_ONLY'] == 'Y' || empty(self::$basketDiscountList))
669 return true;
670 $publicMode = self::usedByClient();
671
672 foreach ($basket as $basketCode => $basketItem)
673 {
674 $code = ($publicMode ? $basketItem['ID'] : $basketCode);
675 if (!static::calculateBasketItemDiscount($code, $basketItem))
676 return false;
677 if (!empty(self::$discountResult['BASKET'][$code]))
678 {
679 foreach (self::$discountResult['BASKET'][$code] as $row)
680 {
681 if ($row['RESULT']['APPLY'] == 'Y')
682 {
683 $basket[$basketCode]['ACTION_APPLIED'] = 'Y';
684 break;
685 }
686 }
687 unset($row);
688 }
689 }
690 unset($basketCode, $basketItem);
691
692 return true;
693 }
694
701 public static function setApplyMode(&$basket)
702 {
703 if (!self::$init)
704 return;
705 if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED)
706 return;
707 if (empty($basket) || !is_array($basket))
708 return;
709 $publicMode = self::usedByClient();
710
712 {
713 case Sale\Discount::APPLY_MODE_DISABLE:
714 case Sale\Discount::APPLY_MODE_FULL_DISABLE:
715 foreach ($basket as $basketCode => $basketItem)
716 {
717 $code = ($publicMode ? $basketItem['ID'] : $basketCode);
718 if (isset(self::$basketDiscountList[$code]) && !empty(self::$basketDiscountList[$code]))
719 $basket[$basketCode]['LAST_DISCOUNT'] = 'Y';
720 unset($code);
721 }
722 unset($basketCode, $basketItem);
723 break;
724 case Sale\Discount::APPLY_MODE_LAST:
725 case Sale\Discount::APPLY_MODE_FULL_LAST:
726 foreach ($basket as $basketCode => $basketItem)
727 {
728 $code = ($publicMode ? $basketItem['ID'] : $basketCode);
729 if (!isset(self::$basketDiscountList[$code]) || empty(self::$basketDiscountList[$code]))
730 continue;
731 $lastDiscount = end(self::$basketDiscountList[$code]);
732 if (!empty($lastDiscount['LAST_DISCOUNT']) && $lastDiscount['LAST_DISCOUNT'] == 'Y')
733 $basket[$basketCode]['LAST_DISCOUNT'] = 'Y';
734 }
735 unset($basketCode, $basketItem);
736 break;
737 case Sale\Discount::APPLY_MODE_ADD:
738 break;
739 }
740 }
741
748 public static function setOrderData($order)
749 {
750 if (array_key_exists('DISCOUNT_DESCR', $order))
751 unset($order['DISCOUNT_DESCR']);
752 if (array_key_exists('DISCOUNT_RESULT', $order))
753 unset($order['DISCOUNT_RESULT']);
754 self::$previousOrderData = $order;
755 }
756
763 public static function setOldDiscountResult($discountList)
764 {
765 self::$compatibleSaleDiscountResult = $discountList;
766 }
767
773 public static function getOldDiscountResult()
774 {
776 }
777
785 public static function calculateSaleDiscount(&$order, $discount)
786 {
787 if (!self::$init)
788 self::init();
789 if (!self::isSuccess())
790 return false;
791
792 $order['DISCOUNT_RESULT'] = Sale\Discount\Actions::getActionResult();
793 $order['DISCOUNT_DESCR'] = Sale\Discount\Actions::getActionDescription();
794 if (!empty($order['DISCOUNT_RESULT']) && is_array($order['DISCOUNT_RESULT']))
795 {
796 $stepResult = self::getStepResult($order);
797 }
798 else
799 {
800 $stepResult = self::getStepResultOld($order);
801 if (!empty($stepResult))
802 {
803 if (empty($order['DISCOUNT_DESCR']) || !is_array($order['DISCOUNT_DESCR']))
804 $order['DISCOUNT_DESCR'] = Discount\Result\CompatibleFormat::getDiscountDescription($stepResult);
805 }
806 }
807 Sale\Discount\Actions::fillCompatibleFields($order);
808 $applied = !empty($stepResult);
809
810 $orderDiscountId = 0;
811 $orderCouponId = '';
812
813 if ($applied)
814 {
815 self::correctStepResult($order, $stepResult, $discount);
816
817 $discount['ACTIONS_DESCR'] = $order['DISCOUNT_DESCR'];
819 if (!$discountResult->isSuccess())
820 return false;
821
822 $orderDiscountId = $discountResult->getId();
823 $discountData = $discountResult->getData();
824 $discount['ORDER_DISCOUNT_ID'] = $orderDiscountId;
825
826 if ($discountData['USE_COUPONS'] == 'Y')
827 {
828 if (empty($discount['COUPON']))
829 return false;
830
831 $couponResult = self::convertCoupon($discount['COUPON']['COUPON'], $orderDiscountId);
832 if (!$couponResult->isSuccess())
833 return false;
834 $orderCouponId = $couponResult->getId();
835 Sale\DiscountCouponsManager::setApply($orderCouponId, $stepResult);
836 unset($couponResult);
837 }
838 }
839
840 unset($order['DISCOUNT_DESCR'], $order['DISCOUNT_RESULT']);
841
842 self::$currentOrderData = $order;
843 if ($applied && $orderCouponId != '')
844 {
845 $couponApply = Sale\DiscountCouponsManager::setApply(self::$couponsCache[$orderCouponId]['COUPON'], $stepResult);
846 unset($couponApply);
847 }
848
849 if ($applied)
850 {
851 if (!empty($stepResult['BASKET']))
852 {
853 $publicMode = self::usedByClient();
854 foreach ($order['BASKET_ITEMS'] as $basketCode => $basketItem)
855 {
856 $code = ($publicMode ? $basketItem['ID'] : $basketCode);
857 if (empty($stepResult['BASKET'][$code]))
858 continue;
859 if ($stepResult['BASKET'][$code]['APPLY'] == 'Y')
860 $order['BASKET_ITEMS'][$basketCode]['ACTION_APPLIED'] = 'Y';
861 }
862 unset($code, $basketCode, $basketItem);
863 unset($publicMode);
864 }
865
866 self::$discountResult['ORDER'][] = array(
867 'DISCOUNT_ID' => $orderDiscountId,
868 'COUPON_ID' => $orderCouponId,
869 'RESULT' => $stepResult
870 );
871 return true;
872 }
873
874 return false;
875 }
876
883 public static function getApplyResult($extMode = false)
884 {
885 $extMode = ($extMode === true);
886
888 if ($extMode)
890
891 $result = self::$discountResult;
892 if ($extMode)
893 unset($result['BASKET'], $result['ORDER']);
894 //$result['CONVERTED_ORDER'] = 'Y';
895 return $result;
896 }
897
905 public static function setBasketCode($index, $code)
906 {
907 self::$basketCodes[$index] = $code;
908 }
909
915 public static function getResult()
916 {
917 if (!self::$init || self::$useMode == self::MODE_SYSTEM)
918 return false;
919 if (self::$useMode == self::MODE_ORDER)
920 return array();
921 if (self::$useMode == self::MODE_DISABLED)
922 return array();
923 $result = array(
924 'CALCULATE' => array(
925 'USE_MODE' => self::$discountUseMode,
926 'NEW_ORDER' => self::$order === null,
927 ),
928 'BASE_PRICE' => array(),
929 'DISCOUNT_LIST' => array(),
930 'COUPONS_LIST' => array(),
931 'DISCOUNT_RESULT' => array(),
932 'FORWARD_BASKET_TABLE' => array(),
933 'REVERSE_BASKET_TABLE' => array()
934 );
935
936 if (!empty(self::$basketBasePrice))
937 {
938 foreach (self::$basketBasePrice as $index => $price)
939 {
940 if (!isset(self::$basketCodes[$index]))
941 continue;
942 $result['BASE_PRICE'][self::$basketCodes[$index]] = $price;
943 }
944 unset($index, $price);
945 }
946
947 if (!empty(self::$discountsCache))
948 $result['DISCOUNT_LIST'] = self::$discountsCache;
949
950 if (!empty(self::$couponsCache))
951 $result['COUPONS_LIST'] = self::$couponsCache;
952
953 if (
954 !empty(self::$discountResult['BASKET'])
955 || !empty(self::$discountResult['ORDER'])
956 || !empty(self::$discountResult['BASKET_ROUND'])
957 )
958 {
959 $result['DISCOUNT_RESULT']['APPLY_BLOCKS'] = array(
960 0 => array(
961 'BASKET' => array(),
962 'BASKET_ROUND' => array(),
963 'ORDER' => array()
964 )
965 );
966 }
967
968 if (!empty(self::$discountResult['BASKET']))
969 {
970 foreach (self::$discountResult['BASKET'] as $index => $discountList)
971 {
972 if (!isset(self::$basketCodes[$index]))
973 continue;
974 $result['DISCOUNT_RESULT']['APPLY_BLOCKS'][0]['BASKET'][self::$basketCodes[$index]] = $discountList;
975 }
976 unset($index, $discountList);
977 }
978
979 if (!empty(self::$discountResult['BASKET_ROUND']))
980 {
981 foreach (self::$discountResult['BASKET_ROUND'] as $index => $roundData)
982 {
983 if (!isset(self::$basketCodes[$index]))
984 continue;
985 $result['DISCOUNT_RESULT']['APPLY_BLOCKS'][0]['BASKET_ROUND'][self::$basketCodes[$index]] = $roundData;
986 }
987 unset($index, $roundData);
988 }
989
990 if (!empty(self::$discountResult['ORDER']))
991 {
992 foreach (self::$discountResult['ORDER'] as $discountIndex => $discount)
993 {
994 if (!empty($discount['RESULT']['BASKET']))
995 {
996 $newBasket = array();
997 foreach ($discount['RESULT']['BASKET'] as $index => $basketItem)
998 {
999 if (!isset(self::$basketCodes[$index]))
1000 continue;
1001 $basketItem['BASKET_ID'] = self::$basketCodes[$index];
1002 $newBasket[self::$basketCodes[$index]] = $basketItem;
1003 }
1004 unset($index, $basketItem);
1005 $discount['RESULT']['BASKET'] = $newBasket;
1006 }
1007 $result['DISCOUNT_RESULT']['APPLY_BLOCKS'][0]['ORDER'][$discountIndex] = $discount;
1008 }
1009 unset($discountIndex, $discount);
1010 }
1011
1012 if (!empty(self::$basketCodes))
1013 {
1014 foreach (self::$basketCodes as $code => $id)
1015 {
1016 $result['FORWARD_BASKET_TABLE'][$code] = $id;
1017 $result['REVERSE_BASKET_TABLE'][$id] = $code;
1018 }
1019 unset($code, $id);
1020 }
1021
1022 return $result;
1023 }
1024
1032 public static function roundPrices(array &$basket, array $orderData = array())
1033 {
1034 if (empty($basket))
1035 return;
1036
1037 $publicMode = self::usedByClient();
1038
1039 $clearedBasket = array();
1040 foreach ($basket as $basketCode => $basketItem)
1041 {
1042 if (\CSaleBasketHelper::isSetItem($basketItem))
1043 continue;
1044 $clearedBasket[$basketCode] = $basketItem;
1045 }
1046 unset($basketCode, $basketItem);
1047
1048 if (!empty($clearedBasket))
1049 {
1050 $result = Sale\OrderDiscountManager::roundBasket(
1051 $clearedBasket,
1052 array(),
1053 $orderData
1054 );
1055 foreach ($result as $basketCode => $roundResult)
1056 {
1057 if (empty($roundResult) || !is_array($roundResult))
1058 continue;
1059
1060 $code = ($publicMode ? $basket[$basketCode]['ID'] : $basketCode);
1061
1062 $basket[$basketCode]['PRICE'] = $roundResult['PRICE'];
1063 $basket[$basketCode]['DISCOUNT_PRICE'] = $roundResult['DISCOUNT_PRICE'];
1064 //TODO: remove this code after create calculation percent of discount
1065 if ($basket[$basketCode]['PRICE'] > $basket[$basketCode]['BASE_PRICE'])
1066 {
1067 $basket[$basketCode]['BASE_PRICE'] = $basket[$basketCode]['PRICE'];
1068 $basket[$basketCode]['DISCOUNT_PRICE'] = 0;
1069 }
1070
1071 if (!isset(self::$discountResult['BASKET_ROUND']))
1072 self::$discountResult['BASKET_ROUND'] = array();
1073 self::$discountResult['BASKET_ROUND'][$code] = array(
1074 'APPLY' => 'Y',
1075 'ROUND_RULE' => $roundResult['ROUND_RULE']
1076 );
1077 }
1078 unset($basketCode, $roundResult, $result);
1079 }
1080 unset($clearedBasket);
1081 unset($publicMode);
1082 }
1083
1090 protected static function isCustomPrice($basketItem)
1091 {
1092 return (
1093 (isset($basketItem['CUSTOM_PRICE']) && $basketItem['CUSTOM_PRICE'] == 'Y')
1094 || (array_key_exists('PRODUCT_PROVIDER_CLASS', $basketItem) && empty($basketItem['PRODUCT_PROVIDER_CLASS']))
1095 );
1096 }
1097
1105 protected static function calculateBasketItemDiscount($code, $fields)
1106 {
1107 if (\CSaleBasketHelper::isSetItem($fields))
1108 return true;
1109 if (empty(self::$basketDiscountList[$code]))
1110 return true;
1111
1112 $itemData = array(
1113 'MODULE_ID' => $fields['MODULE'],
1114 'PRODUCT_ID' => $fields['PRODUCT_ID'],
1115 'BASKET_ID' => $code
1116 );
1117 foreach (self::$basketDiscountList[$code] as $index => $discount)
1118 {
1120 if (!$discountResult->isSuccess())
1121 return false;
1122
1123 $orderDiscountId = $discountResult->getId();
1124 $discountData = $discountResult->getData();
1125 $orderCouponId = '';
1126 self::$basketDiscountList[$code][$index]['ORDER_DISCOUNT_ID'] = $orderDiscountId;
1127 if ($discountData['USE_COUPONS'] == 'Y')
1128 {
1129 if (empty($discount['COUPON']))
1130 return false;
1131
1132 $couponResult = self::convertCoupon($discount['COUPON'], $orderDiscountId);
1133 if (!$couponResult->isSuccess())
1134 return false;
1135
1136 $orderCouponId = $couponResult->getId();
1137 Sale\DiscountCouponsManager::setApplyByProduct($itemData, array($orderCouponId));
1138 unset($couponResult);
1139 }
1140 unset($discountData, $discountResult);
1141 if (!isset(self::$discountResult['BASKET'][$code]))
1142 self::$discountResult['BASKET'][$code] = array();
1143 self::$discountResult['BASKET'][$code][$index] = array(
1144 'DISCOUNT_ID' => $orderDiscountId,
1145 'COUPON_ID' => $orderCouponId,
1146 'RESULT' => array(
1147 'APPLY' => 'Y',
1148 'DESCR' => false,
1149 'DESCR_DATA' => false
1150 )
1151 );
1152
1153 $orderApplication = (
1154 !empty(self::$discountsCache[$orderDiscountId]['APPLICATION'])
1155 ? self::$discountsCache[$orderDiscountId]['APPLICATION']
1156 : null
1157 );
1158 if (!empty($orderApplication))
1159 {
1160 $fields['DISCOUNT_RESULT'] = (
1161 !empty(self::$discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA'])
1162 ? self::$discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA']
1163 : false
1164 );
1165
1166 $applyProduct = null;
1167 eval('$applyProduct='.$orderApplication.';');
1168 if (is_callable($applyProduct))
1169 $applyProduct($fields);
1170 unset($applyProduct);
1171
1172 if (!empty($fields['DISCOUNT_RESULT']))
1173 {
1174 self::$discountResult['BASKET'][$code][$index]['RESULT']['DESCR_DATA'] = $fields['DISCOUNT_RESULT']['BASKET'];
1175 self::$discountResult['BASKET'][$code][$index]['RESULT']['DESCR'] = self::formatDescription($fields['DISCOUNT_RESULT']);
1176 }
1177 unset($fields['DISCOUNT_RESULT']);
1178 }
1179 unset($orderApplication);
1180 }
1181 unset($discount, $index);
1182
1183 return true;
1184 }
1185
1192 protected static function convertDiscount($discount)
1193 {
1194 $result = new Sale\Result();
1195
1196 $discountResult = Sale\OrderDiscountManager::saveDiscount($discount, false);
1197 if (!$discountResult->isSuccess())
1198 {
1199 $result->addErrors($discountResult->getErrors());
1200 unset($discountResult);
1201 return $result;
1202 }
1203 $orderDiscountId = $discountResult->getId();
1204 $discountData = $discountResult->getData();
1205 $resultData = array(
1206 'ORDER_DISCOUNT_ID' => $orderDiscountId,
1207 'USE_COUPONS' => $discountData['USE_COUPONS'],
1208 'MODULE_ID' => $discountData['MODULE_ID'],
1209 );
1210 if (!isset(self::$discountsCache[$orderDiscountId]))
1211 {
1212 $discountData['ACTIONS_DESCR_DATA'] = false;
1213 if (!empty($discountData['ACTIONS_DESCR']) && is_array($discountData['ACTIONS_DESCR']))
1214 {
1215 $discountData['ACTIONS_DESCR_DATA'] = $discountData['ACTIONS_DESCR'];
1216 $discountData['ACTIONS_DESCR'] = self::formatDescription($discountData['ACTIONS_DESCR']);
1217 }
1218 else
1219 {
1220 $discountData['ACTIONS_DESCR'] = false;
1221 }
1222 if (empty($discountData['ACTIONS_DESCR']))
1223 {
1224 $discountData['ACTIONS_DESCR'] = false;
1225 $discountData['ACTIONS_DESCR_DATA'] = false;
1226 }
1227 self::$discountsCache[$orderDiscountId] = $discountData;
1228 }
1229
1230 $result->setId($orderDiscountId);
1231 $result->setData($resultData);
1232 unset($discountData, $resultData, $orderDiscountId);
1233
1234 return $result;
1235 }
1236
1244 protected static function convertCoupon($coupon, $discount)
1245 {
1246 $result = new Sale\Result();
1247
1248 if (!is_array($coupon))
1249 {
1250 $couponData = Sale\DiscountCouponsManager::getEnteredCoupon($coupon, true);
1251 if (empty($couponData))
1252 {
1253 $result->addError(new Main\Entity\EntityError(
1254 Loc::getMessage('BX_SALE_DISCOUNT_ERR_COUPON_NOT_FOUND'),
1255 self::ERROR_ID
1256 ));
1257 return $result;
1258 }
1259 $coupon = array(
1260 'COUPON' => $couponData['COUPON'],
1261 'TYPE' => $couponData['TYPE'],
1262 'COUPON_ID' => $couponData['ID'],
1263 'DATA' => $couponData
1264 );
1265 unset($couponData);
1266 }
1267 $coupon['ORDER_DISCOUNT_ID'] = $discount;
1268 $coupon['ID'] = 0;
1269
1270 $orderCouponId = $coupon['COUPON'];
1271 if (!isset(self::$couponsCache[$orderCouponId]))
1272 self::$couponsCache[$orderCouponId] = $coupon;
1273 $result->setId($orderCouponId);
1274 $result->setData($coupon);
1275 unset($coupon, $orderCouponId);
1276 return $result;
1277 }
1278
1285 protected static function formatDescription($descr)
1286 {
1287 $result = array();
1288 if (empty($descr) || !is_array($descr))
1289 return $result;
1290 if (isset($descr['DELIVERY']))
1291 {
1292 $result['DELIVERY'] = array();
1293 foreach ($descr['DELIVERY'] as $index => $value)
1294 {
1295 $result['DELIVERY'][$index] = Sale\OrderDiscountManager::formatDescription($value);
1296 if ($result['DELIVERY'][$index] == false)
1297 unset($result['DELIVERY'][$index]);
1298 }
1299 unset($value, $index);
1300 if (!empty($result['DELIVERY']))
1301 $result['DELIVERY'] = implode(', ', $result['DELIVERY']);
1302 }
1303 if (isset($descr['BASKET']))
1304 {
1305 $result['BASKET'] = array();
1306 foreach ($descr['BASKET'] as $index => $value)
1307 {
1308 $result['BASKET'][$index] = Sale\OrderDiscountManager::formatDescription($value);
1309 if ($result['BASKET'][$index] == false)
1310 unset($result['BASKET'][$index]);
1311 }
1312 unset($value, $index);
1313 if (!empty($result['BASKET']))
1314 $result['BASKET'] = implode(', ', $result['BASKET']);
1315 }
1316 return $result;
1317 }
1318
1325 protected static function getStepResult($order)
1326 {
1327 $publicMode = self::usedByClient();
1328 $result = array();
1329 $stepResult = &$order['DISCOUNT_RESULT'];
1330 if (!empty($stepResult['DELIVERY']) && is_array($stepResult['DELIVERY']))
1331 {
1332 $result['DELIVERY'] = array(
1333 'APPLY' => 'Y',
1334 'DELIVERY_ID' => (isset($order['DELIVERY_ID']) ? $order['DELIVERY_ID'] : false),
1335 'SHIPMENT_CODE' => (isset($order['SHIPMENT_CODE']) ? $order['SHIPMENT_CODE'] : false),
1336 'DESCR' => Sale\OrderDiscountManager::formatArrayDescription($stepResult['DELIVERY']),
1337 'DESCR_DATA' => $stepResult['DELIVERY'],
1338 'ACTION_BLOCK_LIST' => array_keys($stepResult['DELIVERY'])
1339 );
1340 if (is_array($result['DELIVERY']['DESCR']))
1341 $result['DELIVERY']['DESCR'] = implode(', ', $result['DELIVERY']['DESCR']);
1342 }
1343 if (!empty($stepResult['BASKET']) && is_array($stepResult['BASKET']))
1344 {
1345 if (!isset($result['BASKET']))
1346 $result['BASKET'] = array();
1347 foreach ($stepResult['BASKET'] as $basketCode => $basketResult)
1348 {
1349 $code = ($publicMode ? $order['BASKET_ITEMS'][$basketCode]['ID'] : $basketCode);
1350 $result['BASKET'][$code] = array(
1351 'APPLY' => 'Y',
1352 'DESCR' => Sale\OrderDiscountManager::formatArrayDescription($basketResult),
1353 'DESCR_DATA' => $basketResult,
1354 'MODULE' => $order['BASKET_ITEMS'][$basketCode]['MODULE'],
1355 'PRODUCT_ID' => $order['BASKET_ITEMS'][$basketCode]['PRODUCT_ID'],
1356 'BASKET_ID' => $code,
1357 'ACTION_BLOCK_LIST' => array_keys($basketResult)
1358 );
1359 if (is_array($result['BASKET'][$code]['DESCR']))
1360 $result['BASKET'][$code]['DESCR'] = implode(', ', $result['BASKET'][$code]['DESCR']);
1361 }
1362 unset($code, $basketCode, $basketResult);
1363 }
1364 unset($stepResult);
1365
1366 return $result;
1367 }
1368
1375 protected static function getStepResultOld($currentOrder)
1376 {
1377 $publicMode = self::usedByClient();
1378 $result = array();
1379 if (isset(self::$previousOrderData['PRICE_DELIVERY']) && isset($currentOrder['PRICE_DELIVERY']))
1380 {
1381 if (self::$previousOrderData['PRICE_DELIVERY'] != $currentOrder['PRICE_DELIVERY'])
1382 {
1383 $descr = Discount\Result\CompatibleFormat::createResultDescription(
1384 $currentOrder['PRICE_DELIVERY'],
1385 self::$previousOrderData['PRICE_DELIVERY'],
1386 self::$previousOrderData['CURRENCY']
1387 );
1388 $result['DELIVERY'] = array(
1389 'APPLY' => 'Y',
1390 'DELIVERY_ID' => (isset($currentOrder['DELIVERY_ID']) ? $currentOrder['DELIVERY_ID'] : false),
1391 'SHIPMENT_CODE' => (isset($currentOrder['SHIPMENT_CODE']) ? $currentOrder['SHIPMENT_CODE'] : false),
1392 'DESCR' => implode(', ', Discount\Formatter::formatList($descr)),
1393 'DESCR_DATA' => $descr
1394 );
1395 unset($descr);
1396 }
1397 }
1398 if (!empty(self::$previousOrderData['BASKET_ITEMS']) && !empty($currentOrder['BASKET_ITEMS']))
1399 {
1400 foreach (self::$previousOrderData['BASKET_ITEMS'] as $basketCode => $item)
1401 {
1402 if (!isset($currentOrder['BASKET_ITEMS'][$basketCode]))
1403 continue;
1404 $code = ($publicMode ? $currentOrder['BASKET_ITEMS'][$basketCode]['ID'] : $basketCode);
1405 if ($item['PRICE'] != $currentOrder['BASKET_ITEMS'][$basketCode]['PRICE'])
1406 {
1407 if (!isset($result['BASKET']))
1408 $result['BASKET'] = array();
1409 $descr = Discount\Result\CompatibleFormat::createResultDescription(
1410 $currentOrder['BASKET_ITEMS'][$basketCode]['PRICE'],
1411 $item['PRICE'],
1412 self::$previousOrderData['CURRENCY']
1413 );
1414 $result['BASKET'][$code] = array(
1415 'APPLY' => 'Y',
1416 'DESCR' => implode(', ', Discount\Formatter::formatList($descr)),
1417 'DESCR_DATA' => $descr,
1418 'MODULE' => $currentOrder['BASKET_ITEMS'][$basketCode]['MODULE'],
1419 'PRODUCT_ID' => $currentOrder['BASKET_ITEMS'][$basketCode]['PRODUCT_ID'],
1420 'BASKET_ID' => $code
1421 );
1422 unset($descr);
1423 }
1424 }
1425 }
1426 return $result;
1427 }
1428
1437 protected static function correctStepResult(&$order, &$stepResult, $discount)
1438 {
1439 if ($discount['USE_COUPONS'] == 'Y' && !empty($discount['COUPON']))
1440 {
1441 if (
1442 $discount['COUPON']['TYPE'] == Sale\Internals\DiscountCouponTable::TYPE_BASKET_ROW &&
1443 (!empty($stepResult['BASKET']) && count($stepResult['BASKET']) > 1)
1444 )
1445 {
1446 $publicMode = self::usedByClient();
1447 $maxPrice = 0;
1448 $maxKey = -1;
1449 $basketId = -1;
1450 foreach (self::$previousOrderData['BASKET_ITEMS'] as $key => $item)
1451 {
1452 $resultKey = ($publicMode ? $item['ID'] : $key);
1453 if (isset($stepResult['BASKET'][$resultKey]))
1454 {
1455 if ($maxPrice < $item['PRICE'])
1456 {
1457 $maxPrice = $item['PRICE'];
1458 $maxKey = $key;
1459 $basketId = $resultKey;
1460 }
1461 }
1462 }
1463 unset($key, $item);
1464 $basketKeys = array_keys($order['BASKET_ITEMS']);
1465 foreach ($basketKeys as &$key)
1466 {
1467 if ($key == $maxKey)
1468 continue;
1469 $order['BASKET_ITEMS'][$key] = self::$previousOrderData['BASKET_ITEMS'][$key];
1470 }
1471 unset($key);
1472 $basketKeys = array_keys($stepResult['BASKET']);
1473 foreach ($basketKeys as &$key)
1474 {
1475 if ($key == $basketId)
1476 continue;
1477 unset($stepResult['BASKET'][$key]);
1478 }
1479 unset($key);
1480 unset($basketKeys);
1481 unset($basketId, $maxKey, $maxPrice, $publicMode);
1482 }
1483 }
1484 }
1485
1491 protected static function getApplyDiscounts()
1492 {
1493 $discountApply = array();
1494 $couponApply = array();
1495
1496 self::$discountResult['DISCOUNT_LIST'] = array();
1497 if (!empty(self::$discountsCache))
1498 {
1499 foreach (self::$discountsCache as $id => $discount)
1500 {
1501 self::$discountResult['DISCOUNT_LIST'][$id] = array(
1502 'ID' => $id,
1503 'NAME' => $discount['NAME'],
1504 'MODULE_ID' => $discount['MODULE_ID'],
1505 'DISCOUNT_ID' => $discount['ID'],
1506 'USE_COUPONS' => $discount['USE_COUPONS'],
1507 'ACTIONS_DESCR' => $discount['ACTIONS_DESCR'],
1508 'ACTIONS_DESCR_DATA' => $discount['ACTIONS_DESCR_DATA'],
1509 'APPLY' => 'N',
1510 'EDIT_PAGE_URL' => $discount['EDIT_PAGE_URL']
1511 );
1512 $discountApply[$id] = &self::$discountResult['DISCOUNT_LIST'][$id];
1513 }
1514 unset($id, $discount);
1515 }
1516
1517 self::$discountResult['COUPON_LIST'] = array();
1518 if (!empty(self::$couponsCache))
1519 {
1520 foreach (self::$couponsCache as $id => $coupon)
1521 {
1522 self::$discountResult['COUPON_LIST'][$id] = $coupon;
1523 self::$discountResult['COUPON_LIST'][$id]['APPLY'] = 'N';
1524 $couponApply[$id] = &self::$discountResult['COUPON_LIST'][$id];
1525 }
1526 unset($id, $coupon);
1527 }
1528
1529 if (!empty(self::$discountResult['BASKET']))
1530 {
1531 foreach (self::$discountResult['BASKET'] as $basketCode => $discountList)
1532 {
1533 foreach ($discountList as $discount)
1534 {
1535 if ($discount['RESULT']['APPLY'] == 'Y')
1536 {
1537 if (isset($discountApply[$discount['DISCOUNT_ID']]))
1538 $discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
1539 if (isset($couponApply[$discount['COUPON_ID']]))
1540 $couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
1541 }
1542 }
1543 unset($discount);
1544 }
1545 unset($basketCode, $discountList);
1546 }
1547
1548 if (!empty(self::$discountResult['ORDER']))
1549 {
1550 foreach (self::$discountResult['ORDER'] as $discount)
1551 {
1552 if (!empty($discount['RESULT']['BASKET']))
1553 {
1554 foreach ($discount['RESULT']['BASKET'] as $basketCode => $applyList)
1555 {
1556 if ($applyList['APPLY'] == 'Y')
1557 {
1558 if (isset($discountApply[$discount['DISCOUNT_ID']]))
1559 $discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
1560 if (isset($couponApply[$discount['COUPON_ID']]))
1561 $couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
1562 }
1563 }
1564 unset($basketCode, $applyList);
1565 }
1566 if (!empty($discount['RESULT']['DELIVERY']) && $discount['RESULT']['DELIVERY']['APPLY'] == 'Y')
1567 {
1568 if (isset($discountApply[$discount['DISCOUNT_ID']]))
1569 $discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
1570 if (isset($couponApply[$discount['COUPON_ID']]))
1571 $couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
1572 }
1573 }
1574 unset($discount);
1575 }
1576 unset($discountApply, $couponApply);
1577 }
1578
1584 protected static function remakingDiscountResult()
1585 {
1586 $basket = array();
1587 $delivery = array();
1588
1589 if (!empty(self::$discountResult['BASKET']))
1590 {
1591 foreach (self::$discountResult['BASKET'] as $basketCode => $discountList)
1592 {
1593 if (!isset($basket[$basketCode]))
1594 $basket[$basketCode] = array();
1595 foreach ($discountList as $discount)
1596 {
1597 $basket[$basketCode][] = array(
1598 'DISCOUNT_ID' => $discount['DISCOUNT_ID'],
1599 'COUPON_ID' => $discount['COUPON_ID'],
1600 'APPLY' => $discount['RESULT']['APPLY'],
1601 'DESCR' => $discount['RESULT']['DESCR']
1602 );
1603 }
1604 unset($discount);
1605 }
1606 unset($basketCode, $discountList);
1607 }
1608
1609 if (!empty(self::$discountResult['ORDER']))
1610 {
1611 foreach (self::$discountResult['ORDER'] as $discount)
1612 {
1613 if (!empty($discount['RESULT']['BASKET']))
1614 {
1615 foreach ($discount['RESULT']['BASKET'] as $basketCode => $applyList)
1616 {
1617 if (!isset($basket[$basketCode]))
1618 $basket[$basketCode] = array();
1619 $basket[$basketCode][] = array(
1620 'DISCOUNT_ID' => $discount['DISCOUNT_ID'],
1621 'COUPON_ID' => $discount['COUPON_ID'],
1622 'APPLY' => $applyList['APPLY'],
1623 'DESCR' => $applyList['DESCR']
1624 );
1625 }
1626 unset($basketCode, $applyList);
1627 }
1628 if (!empty($discount['RESULT']['DELIVERY']))
1629 {
1630 $delivery[] = array(
1631 'DISCOUNT_ID' => $discount['DISCOUNT_ID'],
1632 'COUPON_ID' => $discount['COUPON_ID'],
1633 'DELIVERY_ID' => $discount['RESULT']['DELIVERY']['DELIVERY_ID'],
1634 'APPLY' => $discount['RESULT']['DELIVERY']['APPLY'],
1635 'DESCR' => $discount['RESULT']['DELIVERY']['DESCR']
1636 );
1637 }
1638 }
1639 unset($discount);
1640 }
1641
1642 unset($couponApply, $discountApply);
1643 self::$discountResult['RESULT'] = array(
1644 'BASKET' => $basket,
1645 'DELIVERY' => $delivery
1646 );
1647 }
1648}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static initUseMode($mode=self::MODE_CLIENT, $config=array())
static init($mode=self::MODE_CLIENT, $config=array())
static roundPrices(array &$basket, array $orderData=array())
static setBasketItemBasePrice($code, $price, $currency)
static reInit($mode=self::MODE_CLIENT, $config=array())
static correctStepResult(&$order, &$stepResult, $discount)
static formatList(array $actionList)