diff --git a/CHANGELOG.md b/CHANGELOG.md index 6953fb20..236ea421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-10-25 v.6.4.10 +- Добавлена передача трек-номера в заказе из CRM в Bitrix + ## 2023-10-24 v.6.4.9 - Исправлена ошибка при деактивации модуля diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 41e6f2d0..8ca952f2 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -1722,28 +1722,30 @@ class RetailCrmHistory $shipmentColl = $bitrixOrder->getShipmentCollection(); if ($delivery) { + $baseFields = [ + 'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'], + 'PRICE_DELIVERY' => $crmOrder['delivery']['cost'], + 'CURRENCY' => $bitrixOrder->getCurrency(), + 'DELIVERY_NAME' => $delivery->getName(), + 'CUSTOM_PRICE_DELIVERY' => 'Y', + ]; + + if (RetailcrmConfigProvider::getTrackNumberStatus() === 'Y') { + $baseFields['TRACKING_NUMBER'] = $crmOrder['delivery']['data']['trackNumber'] ?? ''; + } + //В коллекции всегда есть одна скрытая системная доставка, к которой относятся нераспределенные товары //Поэтому, если есть только системная доставка, то нужно создать новую if (!$update || $shipmentColl->count() === 1) { $shipment = $shipmentColl->createItem($delivery); - $shipment->setFields([ - 'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'], - 'PRICE_DELIVERY' => $crmOrder['delivery']['cost'], - 'CURRENCY' => $bitrixOrder->getCurrency(), - 'DELIVERY_NAME' => $delivery->getName(), - 'CUSTOM_PRICE_DELIVERY' => 'Y' - ]); + + $shipment->setFields($baseFields); } else { + $baseFields['DELIVERY_ID'] = $deliveryId; + foreach ($shipmentColl as $shipment) { if (!$shipment->isSystem()) { - $shipment->setFields([ - 'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'], - 'PRICE_DELIVERY' => $crmOrder['delivery']['cost'], - 'CURRENCY' => $bitrixOrder->getCurrency(), - 'DELIVERY_ID' => $deliveryId, - 'DELIVERY_NAME' => $delivery->getName(), - 'CUSTOM_PRICE_DELIVERY' => 'Y' - ]); + $shipment->setFields($baseFields); } } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index f9710ef4..453467ea 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена ошибка при деактивации модуля +- Добавлена передача трек-номера в заказе из CRM в Bitrix diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index b6508821..57f54389 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.9', - 'VERSION_DATE' => '2023-10-24 13:00:00' + 'VERSION' => '6.4.10', + 'VERSION_DATE' => '2023-10-25 15:00:00' ]; diff --git a/intaro.retailcrm/lang/en/options.php b/intaro.retailcrm/lang/en/options.php index cc4f84e3..3206b0dd 100644 --- a/intaro.retailcrm/lang/en/options.php +++ b/intaro.retailcrm/lang/en/options.php @@ -112,3 +112,5 @@ $MESS ['DEACTIVATE_MODULE'] = 'Deactivate the module'; $MESS ['WRONG_CREDENTIALS'] = 'Enter the address and authorization key of the CRM system'; $MESS ['Wrong "apiKey" value.'] = 'Invalid authorization key'; + +$MESS ['ORDER_TRACK_NUMBER'] = 'Receive track number'; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index 0d18abf6..7aa480ca 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -171,3 +171,5 @@ $MESS ['DEACTIVATE_MODULE'] = 'Деактивировать модуль'; $MESS ['WRONG_CREDENTIALS'] = 'Введите адрес и ключ авторизации CRM системы'; $MESS ['Wrong "apiKey" value.'] = 'Недействительный ключ авторизации'; + +$MESS ['ORDER_TRACK_NUMBER'] = 'Получать трек-номер'; diff --git a/intaro.retailcrm/lib/component/configprovider.php b/intaro.retailcrm/lib/component/configprovider.php index deacbdf0..b2c27078 100644 --- a/intaro.retailcrm/lib/component/configprovider.php +++ b/intaro.retailcrm/lib/component/configprovider.php @@ -1159,4 +1159,14 @@ class ConfigProvider { return COption::GetOptionString(Constants::MODULE_ID, Constants::SITES_AVAILABLE, null); } + + public static function getTrackNumberStatus() + { + return static::getOption(Constants::RECEIVE_TRACK_NUMBER_DELIVERY); + } + + public static function setTrackNumberStatus($trackNumberStatus) + { + static::setOption(Constants::RECEIVE_TRACK_NUMBER_DELIVERY, $trackNumberStatus); + } } diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 50eded87..2e23bb55 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -104,4 +104,6 @@ class Constants ['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'], ]; public const SITES_AVAILABLE = 'sites_available'; + + public const RECEIVE_TRACK_NUMBER_DELIVERY = 'receive_track_number_delivery'; } diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index ffbd7f52..d50df1da 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -814,6 +814,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $CRM_ORDER_VAT, htmlspecialchars(trim($_POST['order-vat'])) ?: 'N' ); + + ConfigProvider::setTrackNumberStatus(htmlspecialchars(trim($_POST['track-number'])) ?: 'N'); + COption::SetOptionString( $mid, $CRM_COUPON_FIELD, @@ -1027,6 +1030,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $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); + $optionsOrderTrackNumber = ConfigProvider::getTrackNumberStatus(); $canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0)); $sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N'); @@ -2238,6 +2242,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { + + + + + + +