File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/php_interface/init.php
Back
<?php include_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/tools/ammina.stopvirus.php');?><? function dump($var) { echo '<pre>'; var_dump($var); echo '</pre>'; } function Set_price_new($product_id, $AddCart, $price_id = null){ CModule::IncludeModule("iblock"); CModule::IncludeModule("catalog"); //Получаем товар $arSelect = Array("ID","IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM", "IBLOCK_SECTION_ID", "PROPERTY_VES","PROPERTY_XAU","PROPERTY_XAG","PROPERTY_XPT","PROPERTY_XPD","PROPERTY_ROD","CATALOG_GROUP_1","CATALOG_GROUP_2","CATALOG_GROUP_3"); $arFilter = Array("IBLOCK_ID"=>IntVal(21), "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "ID"=>$product_id); $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>1), $arSelect); while($ob = $res->GetNextElement()) { $arProduct = $ob->GetFields(); } //Раздел $arFilter = Array("IBLOCK_ID"=>IntVal(21), "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "ID" =>$arProduct["IBLOCK_SECTION_ID"]); $rsSections = CIBlockSection::GetList(array('SORT' => 'ASC'), $arFilter, false, array("UF_PRICE_1","UF_PRICE_2","UF_PRICE_3")); while($arSction = $rsSections->Fetch()) { $SectionKoff = $arSction; } //Единица измерения товара $arMeasure = \Bitrix\Catalog\ProductTable::getCurrentRatioWithMeasure($product_id); //Список валют - курс металлов $lcur = CCurrency::GetList(($by="name"), ($order="asc"), LANGUAGE_ID); /*$arPrices[0]["VALUE"] = 0; $arPrices[0]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Перевод на карту <span class="question">?</span></span><span class="hidden_price_text">Оплата по реквизитам счета в банке, нужен паспорт РФ и реквизиты.</span></span>'; $arPrices[1]["VALUE"] = 0; $arPrices[1]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Крупный опт <span class="question">?</span></span><span class="hidden_price_text">Большой объем. Подробности по телефону.</span></span>'; $arPrices[2]["VALUE"] = 0; $arPrices[2]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Максимальная <span class="question">?</span></span><span class="hidden_price_text">Подробности по телефону.</span></span>'; */ $arPrices[0]["VALUE"] = 0; $arPrices[0]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Оплата наличными <span class="question">?</span></span><span class="hidden_price_text">Нужен паспорт РФ.</span></span>'; $arPrices[1]["VALUE"] = 0; $arPrices[1]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Перевод на карту <span class="question">?</span></span><span class="hidden_price_text">Оплата по реквизитам счета в банке, нужен паспорт РФ и реквизиты.</span></span>'; $arPrices[2]["VALUE"] = 0; $arPrices[2]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Максимальная <span class="question">?</span></span><span class="hidden_price_text">Подробности по телефону.</span></span>'; while($lcur_res = $lcur->Fetch()) { if($lcur_res["CURRENCY"] == "XAU"): // GOLD $CODE = "XAU"; endif; if($lcur_res["CURRENCY"] == "XAG"): //SILVER $CODE = "XAG"; endif; if($lcur_res["CURRENCY"] == "XPT"): //PLATINUM $CODE = "XPT"; endif; if($lcur_res["CURRENCY"] == "XPD"): //PALLADIUM $CODE = "XPD"; endif; if($lcur_res["CURRENCY"] == "ROD"): //RHODIUM $CODE = "ROD"; endif; //Если единица измерения КГ то вес считаем всегда за КГ иначе берем из свойства товара if($arMeasure[$product_id]['MEASURE']["SYMBOL_INTL"] == "kg"): $WEIGHT = 1000; else: $WEIGHT = $arProduct["PROPERTY_VES_VALUE"]; endif; //Данный тип цены формируется путем суммирования долей драгоценных металлов в изделии (цену на каждый драгметалл уже описал выше, как считаем). После этого полученная цена умножается на коэффициент, который можно будет ввести вручную в админке. Коэффициент надо вводить не на каждый товар, а для товарной категории. Соответственно, ко всем товарам в данной категории будет применим данный коэффициент. //dump($arProduct["PROPERTY_".$CODE."_VALUE"]); if($arProduct["CATALOG_PRICE_1"] && $arProduct["CATALOG_PRICE_1"] !="0.00" && $arProduct["CATALOG_PRICE_1"] !="1.00" && $arProduct["CATALOG_PRICE_1"] !="10.00"): $arPrices[0]["VALUE"] = $arProduct["CATALOG_PRICE_1"]; else: if($SectionKoff["UF_PRICE_1"] == 0 || !$SectionKoff["UF_PRICE_1"]) {$SectionKoff["UF_PRICE_1"] = 1;} if($CODE && $arProduct["PROPERTY_".$CODE."_VALUE"] !=0 && $arProduct["PROPERTY_".$CODE."_VALUE"]): $arProduct["PROPERTY_".$CODE."_VALUE"] = str_replace(",", ".", $arProduct["PROPERTY_".$CODE."_VALUE"]); $arProduct["PROPERTY_".$CODE."_VALUE"] = eval('return '.$arProduct["PROPERTY_".$CODE."_VALUE"].';');; //dump($arProduct["PROPERTY_".$CODE."_VALUE"]); $arPrices[0]["VALUE"] = $arPrices[0]["VALUE"] + ($WEIGHT / 100 * $arProduct["PROPERTY_".$CODE."_VALUE"] * $lcur_res["AMOUNT"] * $SectionKoff["UF_PRICE_1"]); endif; endif; unset($CODE); } //Это цена будет больше цены 1 на определенный процент, который можно будет также задавать через админку, отдельно для каждой товарной категории. if($arProduct["CATALOG_PRICE_2"] && $arProduct["CATALOG_PRICE_2"] != "0.00"): $arPrices[1]["VALUE"] = $arProduct["CATALOG_PRICE_2"]; else: $arPrices[1]["VALUE"] = $arPrices[0]["VALUE"] * $SectionKoff["UF_PRICE_2"]; endif; //Это цена будет больше цены 2 на определенный процент, который можно будет также задавать через админку, отдельно для каждой товарной категории. if($arProduct["CATALOG_PRICE_3"] && $arProduct["CATALOG_PRICE_3"] != "0.00"): $arPrices[2]["VALUE"] = $arProduct["CATALOG_PRICE_3"]; else: $arPrices[2]["VALUE"] = $arPrices[1]["VALUE"] * $SectionKoff["UF_PRICE_3"]; endif; //Убираем цены если не задан коэффициент в разделе if($SectionKoff["UF_PRICE_2"] == 0 || !$SectionKoff["UF_PRICE_2"]) {unset($arPrices[1]);} if($SectionKoff["UF_PRICE_3"] == 0 || !$SectionKoff["UF_PRICE_3"]) {unset($arPrices[2]);} //Ваша цена $name_el_price = "PRICECUSTOM_".$arProduct["ID"]; if($_COOKIE[$name_el_price]): $arPrices[3]["VALUE"] = $_COOKIE[$name_el_price]; $arPrices[3]["NAME"] = '<span class="price_custom_wrap"><span class="name_pr">Ваша цена</span></span>'; endif; //return //Вывод в front end if($AddCart == "N"): echo('<div class="price_matrix_block">'); foreach ($arPrices as $price){ printf( '<div class="price_group">'. '<div class="price_name">'.$price["NAME"].'</div>'. '<div class="price_matrix_wrapper"> <div class="price" data-currency="RUB" data-value="'.$price["VALUE"].'"> <span> <span class="values_wrapper">'.CurrencyFormat($price["VALUE"], 'RUB').'</span> <span class="price_measure">/'.$arMeasure[$product_id]['MEASURE']['SYMBOL_RUS'].'</span> </span> </div> </div>'. '</div>' ); } echo('</div>'); endif; //Если для смены цены в корзине if($AddCart == "Y" && !$price_id): /*if($arPrices[3]["VALUE"]){ return($arPrices[3]["VALUE"]); }else{*/ return($arPrices[0]["VALUE"]); //} endif; if($AddCart == "Y" && $price_id): return($arPrices[$price_id]["VALUE"]); endif; } //Меняем цену у добавляемого товара в корзину AddEventHandler("catalog", "OnGetOptimalPrice", "MyGetOptimalPrice"); function MyGetOptimalPrice( $intProductID, $quantity = 1, $arUserGroups = array(), $renewal = "N", $arPrices = array(), $siteID = false, $arDiscountCoupons = false ){ return array( "PRICE" => array( "ID" => $intProductID, "CATALOG_GROUP_ID" => 1, "PRICE" => Set_price_new($intProductID,"Y"), "CURRENCY" => "RUB", "ELEMENT_IBLOCK_ID" => 21, "VAT_RATE" => 0, "VAT_INCLUDED" => "Y" ), ); } /*AddEventHandler("sale", "OnBasketAdd", "AddPriceToBasket"); function AddPriceToBasket($ID, $arFields) { $arFieldsPrice = array( "PROPS"=>array( array("NAME" => "Оплата наличными", "CODE" => "PRICE_1", "VALUE" => CurrencyFormat(Set_price_new($intProductID,"Y",0), "RUB"), "SORT" => "10"), array("NAME" => "Перевод на карту", "CODE" => "PRICE_2", "VALUE" => CurrencyFormat(Set_price_new($intProductID,"Y",1), "RUB"), "SORT" => "10"), array("NAME" => "Максимальная", "CODE" => "PRICE_3", "VALUE" => CurrencyFormat(Set_price_new($intProductID,"Y",2), "RUB"), "SORT" => "10"), array("NAME" => "Ваша цена", "CODE" => "PRICE_4", "VALUE" => CurrencyFormat(Set_price_new($intProductID,"Y",3), "RUB"), "SORT" => "10"), ) ); CSaleBasket::Update($ID, $arFieldsPrice); }*/ ?>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.25 |
proxy
|
phpinfo
|
Settings