diff --git a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php index 6aaaa6de..789db8b6 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php +++ b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php @@ -517,6 +517,16 @@ class RetailcrmConfigProvider return static::$shops; } + /** + * isPhoneRequired + * + * @return bool|string|null + */ + public static function isPhoneRequired() + { + return COption::GetOptionString("main", "new_user_phone_required") === 'Y'; + } + /** * Wraps Bitrix COption::GetOptionString(...) * diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 0e2a5683..c137aa1b 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -81,6 +81,13 @@ class RetailCrmHistory continue; } + if (RetailcrmConfigProvider::isPhoneRequired()) { + if (empty($customer['phones'])) { + Logger::getInstance()->write('$customer["phones"] is empty. Customer ' . $customer['id'] . ' cannot be created', 'createCustomerError'); + continue; + } + } + if (isset($customer['externalId']) && !is_numeric($customer['externalId'])) { unset($customer['externalId']); } @@ -368,6 +375,13 @@ class RetailCrmHistory continue; } + if (RetailcrmConfigProvider::isPhoneRequired()) { + if (empty($order['customer']['phones'])) { + Logger::getInstance()->write('$customer["phones"] is empty. Order ' . $order['id'] . ' cannot be created', 'createCustomerError'); + continue; + } + } + $login = null; $registerNewUser = true; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index 4f85b282..9e3bbd30 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -104,3 +104,4 @@ $MESS['ROUND_HEADER'] = "При включенной опции округлен $MESS['PURCHASE_ICML'] = "При включенной опции в генерации icml будет добавлен сброс закупочной цены на 0 если она не указана"; $MESS['PURCHASE_HEADER'] = "Сброс закупочной цены в icml"; +$MESS['PHONE_REQUIRED'] = "В настройках главного модуля была включена опция «Номер телефона является обязательным», что может вызвать проблемы с обратной синхронизацией. Для корректной работы необходимо отключить данную опцию."; diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index 3d6bb143..27ff35db 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -60,6 +60,10 @@ if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale' $_GET['errc'] = htmlspecialchars(trim($_GET['errc'])); $_GET['ok'] = htmlspecialchars(trim($_GET['ok'])); +if (RetailcrmConfigProvider::isPhoneRequired()) { + echo ShowMessage(array("TYPE"=>"ERROR", "MESSAGE"=>GetMessage('PHONE_REQUIRED'))); +} + if($_GET['errc']) echo CAdminMessage::ShowMessage(GetMessage($_GET['errc'])); if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('ICRM_OPTIONS_OK'));