Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
recurring.php
1<?php
8namespace Bitrix\Sale;
9
10use Bitrix\Main;
11
12Main\Localization\Loc::loadMessages(__FILE__);
13
19{
26 public static function repeat(Order $order, array $resultList)
27 {
28 $recurringID = intval($order->getField("RECURRING_ID"));
29
30 $basket = $order->getBasket();
31 foreach ($resultList as $providerName => $basketList)
32 {
33 foreach ($basketList as $basketCode => $resultData)
34 {
35 if ($order->isPaid())
36 {
37 if (!empty($resultData) && is_array($resultData))
38 {
39 if (empty($resultData['ORDER_ID']) || intval($resultData['ORDER_ID']) < 0)
40 $resultData["ORDER_ID"] = $order->getId();
41
42 $resultData["REMAINING_ATTEMPTS"] = (defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3);
43 $resultData["SUCCESS_PAYMENT"] = "Y";
44
45 if ($recurringID > 0)
46 \CSaleRecurring::Update($recurringID, $resultData);
47 else
48 \CSaleRecurring::Add($resultData);
49 }
50 elseif ($recurringID > 0)
51 {
52 \CSaleRecurring::Delete($recurringID);
53 }
54 }
55 else
56 {
57 if (!$basketItem = $basket->getItemByBasketCode($basketCode))
58 {
59 throw new Main\ObjectNotFoundException('Entity "BasketItem" not found');
60 }
61
62 $resRecurring = \CSaleRecurring::GetList(
63 array(),
64 array(
65 "USER_ID" => $order->getUserId(),
66 "PRODUCT_ID" => $basketItem->getProductId(),
67 "MODULE" => $basketItem->getField("MODULE"),
68 "ORDER_ID" => $order->getId(),
69 )
70 );
71 while ($recurringData = $resRecurring->Fetch())
72 {
73 \CSaleRecurring::Delete($recurringData["ID"]);
74 }
75 }
76 }
77 }
78 }
79}
static repeat(Order $order, array $resultList)
Definition recurring.php:26