Revisions
-
tikijian revised this gist
Dec 5, 2012 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,20 +26,20 @@ function OnGetOptimalPriceHandler($productID) $db_res = CPrice::GetList( array(), array( "PRODUCT_ID" => $productID, "CATALOG_GROUP_ID" => $priceID['ID'] ), false, false, array() ); $price = $db_res->Fetch(); $arFields['PRICE'] = array("ID" => $price['ID'], "CATALOG_GROUP_ID" => $price['CATALOG_GROUP_ID'], "PRICE" => $price['PRICE'], "ELEMENT_IBLOCK_ID" => $price['PRODUCT_ID'], "CURRENCY" => $price['CURRENCY'], "VAT_RATE" => "", "VAT_INCLUDED" => 'N' ); return $arFields; -
tikijian created this gist
Dec 5, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ <?php //событие подмены нужной цены для покупки услуг AddEventHandler("catalog", "OnGetOptimalPrice", 'OnGetOptimalPriceHandler'); function OnGetOptimalPriceHandler($productID) { //получаем id инфоблока покупаемого товара. Если это услуга, то подменяем цену. $db_iblock = CIBlockElement::GetList(array(), array("ID" => $productID), false, false, array("IBLOCK_ID")); $iblock = $db_iblock->Fetch(); if( $iblock['IBLOCK_ID'] == CATALOG_SERV ){ if (isset($GLOBALS['COMPLEXITY_AR']) && !empty($GLOBALS['COMPLEXITY_AR']['NAME'])) $complexity = $GLOBALS['COMPLEXITY_AR']['NAME']; //устанавливается при выборе автомобиля else return true; $dbPrice = CCatalogGroup::GetList( array(), array("NAME" => $complexity), false, false, array("ID") ); $priceID = $dbPrice->Fetch(); $db_res = CPrice::GetList( array(), array( "PRODUCT_ID" => $productID, "CATALOG_GROUP_ID" => $priceID['ID'] ), false, false, array() ); $price = $db_res->Fetch(); $arFields['PRICE'] = array("ID" => $price['ID'], "CATALOG_GROUP_ID" => $price['CATALOG_GROUP_ID'], "PRICE" => $price['PRICE'], "ELEMENT_IBLOCK_ID" => $price['PRODUCT_ID'], "CURRENCY" => $price['CURRENCY'], "VAT_RATE" => "", "VAT_INCLUDED" => 'N' ); return $arFields; }else{ //это обычный товар - значит стандартное поведение return true; } } ?>