1
0
mirror of synced 2025-01-31 23:31:41 +03:00

fixes due to status and site

This commit is contained in:
Grisha Pomadchin 2013-11-15 15:55:54 +04:00
parent 8f2d6befbc
commit 63d03327f3
2 changed files with 22 additions and 8 deletions

View File

@ -282,8 +282,10 @@ class ICrmOrderActions
$defaultSiteId = 0;
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y'));
while ($ar = $rsSites->Fetch())
while ($ar = $rsSites->Fetch()) {
$defaultSiteId = $ar['LID'];
break;
}
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);

View File

@ -158,7 +158,7 @@ class ICrmOrderEvent {
* @return boolean
*/
function onSaleCancelOrder($ID, $cancel, $reason) {
if(!$ID || !$cancel || ($cancel != 'Y'))
if(!$ID || !$cancel)
return true;
if (!CModule::IncludeModule('iblock')) {
@ -186,12 +186,24 @@ class ICrmOrderEvent {
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
$api = new IntaroCrm\RestApi($api_host, $api_key);
$order = array(
'externalId' => (int) $ID,
'status' => $optionsPayStatuses[$cancel.$cancel],
'statusComment' => ICrmOrderActions::toJSON($reason)
);
$order = array();
if($cancel == 'Y') {
$order = array(
'externalId' => (int) $ID,
'status' => $optionsPayStatuses[$cancel.$cancel],
'statusComment' => ICrmOrderActions::toJSON($reason)
);
} else if($cancel == 'N') {
$arOrder = CSaleOrder::GetById((int) $ID);
$order = array(
'externalId' => (int) $ID,
'status' => $optionsPayStatuses[$arOrder['STATUS_ID']],
'managerComment' => $arOrder['COMMENTS']
);
}
$api->orderEdit($order);