From 4bc57cc63aa828a4774218151ebaa22e3e0ca928 Mon Sep 17 00:00:00 2001 From: b12 Date: Wed, 25 Dec 2013 18:38:25 +0400 Subject: [PATCH] fix bugs in product status processing --- .../classes/general/ICrmOrderActions.php | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 135662ec..49aa8e0b 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -585,13 +585,15 @@ class ICrmOrderActions if (!$p) { $p = CIBlockElement::GetByID($item['offer']['externalId'])->Fetch(); - $p[self::CANCEL_PROPERTY_CODE] = 0; } else { //for basket props updating (in props we save cancel status) $propResult = CSaleBasket::GetPropsList( - array(), - array('BASKET_ID' => $p['ID']) + array(''), + array('BASKET_ID' => $p['ID']), + false, + false, + array('NAME', 'CODE', 'VALUE', 'SORT') ); while($r = $propResult->Fetch()) { @@ -619,7 +621,7 @@ class ICrmOrderActions 'DELAY' => $p['DELAY'], 'CAN_BUY' => $p['CAN_BUY'], 'MODULE' => $p['MODULE'], - 'NOTES' => $p['NOTES'], + 'NOTES' => $item['comment'] ?: $p['NOTES'], 'PRODUCT_PROVIDER_CLASS' => $p['PRODUCT_PROVIDER_CLASS'], 'DETAIL_PAGE_URL' => $p['DETAIL_PAGE_URL'], 'CATALOG_XML_ID' => $p['CATALOG_XML_ID'], @@ -649,7 +651,7 @@ class ICrmOrderActions if (isset($item['isCanceled'])) { //for product excluding from order $arProduct['PRICE'] = 0; - self::updateCancelProp($arProduct, 1); + $arProduct = self::updateCancelProp($arProduct, 1); } CSaleBasket::Add($arProduct); @@ -658,7 +660,7 @@ class ICrmOrderActions $arProduct['PROPS'] = $p['PROPS']; - if (!isset($item['isCanceled']) { + if (!isset($item['isCanceled'])) { // update old if (isset($item['initialPrice']) && $item['initialPrice']) $arProduct['PRICE'] = (double) $item['initialPrice']; @@ -676,12 +678,12 @@ class ICrmOrderActions if(isset($item['discount']) || isset($item['discountPercent'])) $arProduct['PRICE'] -= $arProduct['DISCOUNT_PRICE']; - self::updateCancelProp($arProduct, 0); + $arProduct = self::updateCancelProp($arProduct, 0); } else { //for product excluding from order $arProduct['PRICE'] = 0; - self::updateCancelProp($arProduct, 1); + $arProduct = self::updateCancelProp($arProduct, 1); } @@ -938,6 +940,7 @@ class ICrmOrderActions array(), array('BASKET_ID' => $p['ID'], 'CODE' => self::CANCEL_PROPERTY_CODE) )->Fetch(); + if ($propCancel) { $propCancel = (int)$propCancel['VALUE']; } @@ -948,18 +951,21 @@ class ICrmOrderActions else $pr = ''; - $items[] = array( + $item = array( 'discountPercent' => 0, 'quantity' => $p['QUANTITY'], 'productId' => $p['PRODUCT_ID'], - 'productName' => self::toJSON($p['NAME']) + 'productName' => self::toJSON($p['NAME']), + 'comment' => $p['NOTES'], ); //if it is canceled product don't send price if (!$propCancel) { - $items['initialPrice'] = (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE']; - $items['discount'] => $p['DISCOUNT_PRICE'] + $item['initialPrice'] = (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE']; + $item['discount'] = $p['DISCOUNT_PRICE']; } + + $items[] = $item; } if($arFields['CANCELED'] == 'Y')