Skip to content

Instantly share code, notes, and snippets.

<?php
// ключ для соединения
$key = '6f4cb12fa15962e18c31942a3e4a73f6';
// код товара
$code = '110086';
// запрос
$curl = curl_init('https://api.samsonopt.ru/v1/sku/' . $code . '/stock/?api_key=' . $key);
<?
$context = Bitrix\Main\Application::getInstance()->getContext();
$request = $context->getCurrent()->getRequest();
/*
Отслеживаем 3 GET-параметра: title, subtitle и text (заголовок, подзаголовок и текст)
Соответствие между GET-параметром и значением хранится в инфоблоке с ID = SUBSTUTUTION_IBLOCK
в свойствах с символьными кодами TITLE, SUBTITLE и TEXT соответственно
А сами значения в TITLE_VAL, SUBTITLE_VAL и TEXT_VAL
*/
AddEventHandler("main", "OnEndBufferContent", "deleteKernel");
function deleteKernel(&$content) {
global $APPLICATION;
if (strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false) {
return;
}
$arPatternsToRemove = Array(
//Убираем лишние скрипты битрикса*/
<?
class YoutubeVideo
{
function __construct($video)
{
$this->video = $video;
}
private function Prefix()
// reCaptcha
$url = 'https://www.google.com/recaptcha/api/siteverify';
// data POST
$secret = '******';
$response = $_REQUEST['g-recaptcha-response'];
$remoteip = $_SERVER['REMOTE_ADDR'];
$urlData = $url . '?secret=' . $secret . '&response=' . $response . '&remoteip=' . $remoteip;
$curl = curl_init();
@bxtimur
bxtimur / Прокрутка наверх
Created February 23, 2018 08:02
Кнопка прокрутки наверх
<div class="scroll-up" style="display: block;"></div>
<style>
.scroll-up {
width: 45px;
height: 45px;
border-radius: 25px;
background: #fb5f41;
position: fixed;
z-index: 9999;
// возвращает названия дерева разделов элемента через запятую
function GetParentSections ($id, $arTags) {
\Bitrix\Main\Loader::includeModule('iblock');
if (!$arTags)
$arTags = array();
$objResult = CIBlockSection::GetList(
array(), array("ID" => $id, "IBLOCK_ID" => CATALOG_IBLOCK_ID), false, array("ID", "NAME", "IBLOCK_SECTION_ID", "DEPTH_LEVEL"), false
);
$arResult = $objResult->GetNext();
@bxtimur
bxtimur / gist:41192c59b91267e08bd2c4b2a12375ae
Created October 20, 2017 15:32
Отправка доп. полей в письме при новом заказе Битрикс
AddEventHandler("sale", "OnOrderNewSendEmail", "bxModifySaleMails");
function bxModifySaleMails($orderID, &$eventName, &$arFields) {
$additional_information = '';
$arOrder = CSaleOrder::GetByID($orderID);
$order_props = CSaleOrderPropsValue::GetOrderProps($orderID);
while ($arProps = $order_props->Fetch()){
// телефон
if ($arProps['ORDER_PROPS_ID'] == 14){
$additional_information.='Телефон: '.$arProps['VALUE'].'<br>';
// Uniqueness of the element's code
AddEventHandler("iblock", "OnAfterIBlockElementAdd", "UniquenessCode");
function UniquenessCode (&$arFields) {
if ($arFields["IBLOCK_ID"] == CATALOG_IBLOCK_ID && !empty($arFields["CODE"])) {
$code = $arFields["CODE"] . "-" . $arFields["ID"];
$code = str_replace("--", "-", $code);
$objElement = new CIBlockElement;
$objElement->Update($arFields["ID"], array("CODE" => $code));
}
// Canonical
$curpage = $APPLICATION->GetCurUri();
$arPagen = array('PAGEN_1', 'PAGEN_2');
foreach ($arPagen as $pageParam) {
if (strpos($curpage, $pageParam) !== false) {
$newpage = 'http';
$newpage .= $_SERVER["HTTPS"] ? 's' : '';
$newpage .= '://' . $_SERVER["SERVER_NAME"];
$newpage .= $APPLICATION->GetCurPage(false);
$APPLICATION->AddHeadString('<link rel="canonical" href="' . $newpage . '" />');