diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index c8f39018..f2651d73 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -311,20 +311,20 @@ class ICrmOrderActions if(!isset($order['externalId']) && !$order['externalId']) { - // we dont need new orders without any customers - if(!isset($order['customer']) && !$order['customer']) + // we dont need new orders without any customers (can check only for externalId) + if(!isset($order['customer']['externalId']) && !$order['customer']['externalId']) continue; // new order $newOrderFields = array( - 'LID' => $defaultSiteId, //<----! - 'PERSON_TYPE_ID' => $optionsOrderTypes[$order['orderType']], // <------! + 'LID' => $defaultSiteId, + 'PERSON_TYPE_ID' => $optionsOrderTypes[$order['orderType']], 'PAYED' => 'N', 'CANCELED' => 'N', 'STATUS_ID' => 'N', 'PRICE' => 0, 'CURRENCY' => 'RUB', - 'USER_ID' => $order['customer'], // <--------! + 'USER_ID' => $order['customer']['externalId'], 'PAY_SYSTEM_ID' => 0, 'PRICE_DELIVERY' => 0, 'DELIVERY_ID' => 0, @@ -356,9 +356,11 @@ class ICrmOrderActions if(!$arFields || empty($arFields)) continue; - $userId = $arFields['USER_ID']; - if(isset($order['customer']) && $order['customer']) $userId = $order['customer']; $LID = $arFields['LID']; + $userId = $arFields['USER_ID']; + + if(isset($order['customer']['externalId']) && $order['customer']['externalId']) + $userId = $order['customer']['externalId']; $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); @@ -415,17 +417,17 @@ class ICrmOrderActions switch ($ar['CODE']) { case $optionsOrderProps[$arFields['PERSON_TYPE_ID']]['fio']: - if (isset($order['firstName'])) - $contactName['firstName'] = self::fromJSON($order['firstName']); - if (isset($order['lastName'])) - $contactName['lastName'] = self::fromJSON($order['lastName']); - if (isset($order['patronymic'])) - $contactName['patronymic'] = self::fromJSON($order['patronymic']); + if (isset($order['firstName'])) + $contactName['firstName'] = self::fromJSON($order['firstName']); + if (isset($order['lastName'])) + $contactName['lastName'] = self::fromJSON($order['lastName']); + if (isset($order['patronymic'])) + $contactName['patronymic'] = self::fromJSON($order['patronymic']); - if (!isset($contactName) || empty($contactName)) - break; + if (!isset($contactName) || empty($contactName)) + break; - CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => implode(" ", $contactName))); + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => implode(" ", $contactName))); break; case $optionsOrderProps[$arFields['PERSON_TYPE_ID']]['phone']: if (isset($order['phone'])) CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['phone']))); diff --git a/intaro.intarocrm/install/version.php b/intaro.intarocrm/install/version.php index 2eb60667..60fd4cd8 100644 --- a/intaro.intarocrm/install/version.php +++ b/intaro.intarocrm/install/version.php @@ -1,5 +1,5 @@ "0.4.3", - "VERSION_DATE" => "2013-10-30 16:04:00", + "VERSION_DATE" => "2013-10-31 10:47:00", ); \ No newline at end of file