diff --git a/CHANGELOG.md b/CHANGELOG.md index 0929c39a..ff22aa3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-10-17 v.6.4.8 +- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM + ## 2023-10-10 v.6.4.7 - Изменена логика передачи адреса доставки в заказе из Bitrix в CRM diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 25bb1c23..5292c5f3 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -120,8 +120,7 @@ class RetailCrmOrder $order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arOrder['PERSON_TYPE_ID']]; - - $countryList = RetailCrmService::getCountryList(); + $countryList = BitrixOrderService::getCountryList(); $deliveryAddress = ['city' => '', 'text' => '', 'index' => '', 'region' => '', 'countryIso' => '']; //Order fields @@ -175,10 +174,19 @@ class RetailCrmOrder } } - // Clear empty fields + // Удаляем пустые значения $deliveryAddress = array_filter($deliveryAddress); - if (!empty($deliveryAddress)) { + // Пункт самовывоза + $pickupPointAddress = ''; + + if (RetailcrmConfigProvider::needSendPickupPointAddress() === 'Y') { + $pickupPointAddress = BitrixOrderService::getPickupPointAddress($arOrder); + } + + if ($pickupPointAddress !== '') { + $order['delivery']['address']['text'] = $pickupPointAddress; + } elseif(!empty($deliveryAddress)) { $order['delivery']['address'] = $deliveryAddress; } diff --git a/intaro.retailcrm/classes/general/services/BitrixOrderService.php b/intaro.retailcrm/classes/general/services/BitrixOrderService.php new file mode 100644 index 00000000..f0f3c9ae --- /dev/null +++ b/intaro.retailcrm/classes/general/services/BitrixOrderService.php @@ -0,0 +1,50 @@ +getServer()->getDocumentRoot(); + $countryList = []; + + if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { + $countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); + + foreach ($countryFile->country as $country) { + $countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; + } + } + + return $countryList; + } + + public static function getPickupPointAddress($arOrder) + { + $address = ''; + $orderInfo = Order::load($arOrder['ID']); + + foreach ($orderInfo->getShipmentCollection() as $store) { + $storeId = $store->getStoreId(); + + if ($storeId) { + $arStore = StoreTable::getRow([ + 'filter' => [ + 'ID' => $storeId, + ] + ]); + + if (!empty($arStore['ADDRESS'])) { + $address = GetMessage('PICKUP_POINT') . $arStore['ADDRESS']; + + break; + } + } + } + + return $address; + } +} diff --git a/intaro.retailcrm/classes/general/services/RetailCrmService.php b/intaro.retailcrm/classes/general/services/RetailCrmService.php index 2978eb6f..58081426 100644 --- a/intaro.retailcrm/classes/general/services/RetailCrmService.php +++ b/intaro.retailcrm/classes/general/services/RetailCrmService.php @@ -1,7 +1,5 @@ getServer()->getDocumentRoot(); - $countryList = []; - - if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { - $countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); - - foreach ($countryFile->country as $country) { - $countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; - } - } - - return $countryList; - } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 6d3d910a..b526db0b 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Изменена логика передачи адреса доставки в заказе из Bitrix в CRM +- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 7c5315c8..4a7de548 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.7', - 'VERSION_DATE' => '2023-10-10 18:00:00' + 'VERSION' => '6.4.8', + 'VERSION_DATE' => '2023-10-17 18:00:00' ]; diff --git a/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php b/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php deleted file mode 100644 index dd398abf..00000000 --- a/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php +++ /dev/null @@ -1,4 +0,0 @@ - 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'], ['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'], diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index d00bee64..51413dd2 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -406,13 +406,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); } - //order numbers - $orderVat = htmlspecialchars(trim($_POST['order-vat'])) ?: 'N'; - $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N'; - $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N'; - $sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N'; - $crmCouponFiled = htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N'; - //stores $bitrixStoresArr = []; $bitrixShopsArr = []; @@ -810,17 +803,22 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { COption::SetOptionString( $mid, $CRM_ORDER_NUMBERS, - $orderNumbers + htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N' ); COption::SetOptionString( $mid, $CRM_ORDER_VAT, - $orderVat + htmlspecialchars(trim($_POST['order-vat'])) ?: 'N' ); COption::SetOptionString( $mid, $CRM_COUPON_FIELD, - $crmCouponFiled + htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N' + ); + COption::SetOptionString( + $mid, + Constants::CRM_SEND_PICKUP_POINT_ADDRESS, + htmlspecialchars(trim($_POST['send-pickup-point-address'])) ?: 'N' ); COption::SetOptionString( $mid, @@ -894,9 +892,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { COption::SetOptionString( $mid, $CRM_DIMENSIONS, - $orderDimensions + htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N' ); - RetailcrmConfigProvider::setSendPaymentAmount($sendPaymentAmount); + RetailcrmConfigProvider::setSendPaymentAmount(htmlspecialchars(trim($_POST[Constants::SEND_PAYMENT_AMOUNT])) ?: 'N'); RetailCrmConfigProvider::setDiscountRound($discount_round); RetailcrmConfigProvider::setCart($optionCart); COption::SetOptionString( @@ -1024,8 +1022,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0)); $optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0)); $optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0); - $optionsOrderVat= COption::GetOptionString($mid, $CRM_ORDER_VAT, 0); + $optionsOrderVat = COption::GetOptionString($mid, $CRM_ORDER_VAT, 0); $canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0)); + $sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N'); $optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0); $optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0)); @@ -2194,6 +2193,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { return false; }); + + $('input[name="send-pickup-point-address"]').change( + function(){ + if ($(this).is(':checked')) { + alert(''); + } + }); }); @@ -2237,6 +2243,32 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { +