Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
d1i1m1o1n / gist:0fb73df491d8fd3d8596
Last active November 15, 2015 21:27 — forked from marvell/gist:8330935
Bitrix: получение оптимальной цены (с учетом скидок) #snippet
CModule::IncludeModule("catalog");
global $USER;
//Цена
$arPrice = CCatalogProduct::GetOptimalPrice($arResult['ID'], 1, $USER->GetUserGroupArray());
$arResult['PRICE'] = $arPrice;
$arResult['DISCOUNT_PRICE'] = SaleFormatCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["RESULT_PRICE"]["CURRENCY"]);
@d1i1m1o1n
d1i1m1o1n / header.php
Created November 23, 2015 14:32
Bitrix. Set data in component template and output in site template
<?php if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<div id="content">
<?php $APPLICATION->ShowViewContent('content'); ?>
</div>
@d1i1m1o1n
d1i1m1o1n / form.php
Created November 23, 2015 14:33
Bitrix. Standart bitrix form
<form method="post" action="<?php echo POST_FORM_ACTION_URI?>">
<?php echo bitrix_sessid_post()?>
<input type="submit" name="submit" value="Submit">
</form>
@d1i1m1o1n
d1i1m1o1n / empty.php
Created November 23, 2015 14:34
Bitrix. Page without header and footer
<?php
define('NO_AGENT_CHECK', true);
define("STOP_STATISTICS", true);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
//ajax
/*if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || empty($_SERVER['HTTP_X_REQUESTED_WITH'])
|| strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') return;*/
@d1i1m1o1n
d1i1m1o1n / .htaccess
Created November 23, 2015 14:35
Bitrix .htaccess
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag session.use_trans_sid off
php_value display_errors 1
php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
@d1i1m1o1n
d1i1m1o1n / bitrixOneClickOrder.php
Created December 8, 2015 12:44
Заказ в один клик Bitrix
<?php
require_once($_SERVER['DOCUMENT_ROOT']. "/bitrix/modules/main/include/prolog_before.php");
// добавление заказа в один клик, только по имени и телефону
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
if(!empty($_REQUEST['name']) && !empty($_REQUEST['phone']))
{
$name = $_REQUEST['name'];
<?define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt");
AddMessage2Log('Моя мессага');?>
<?if(CModule::IncludeModule("sale"))
echo Number2Word_Rus(1425.43);?>
@d1i1m1o1n
d1i1m1o1n / file.php
Created February 19, 2016 08:13
PHP: Get coordinates by address.
<?php
$adress = urlencode("Москва, Тверская улица, дом 7");
$url = "http://geocode-maps.yandex.ru/1.x/?geocode={$adress}";
$content = file_get_contents($url);
preg_match("/<pos>(.*?)<\/pos>/", $content, $point);
$coords = str_replace(' ', ', ', trim(strip_tags($point[1])));
echo $coords;
// результат: 38.241803, 56.300984
@d1i1m1o1n
d1i1m1o1n / debug.php
Created February 19, 2016 08:18
Bitrix(d7). Debug
<?php
use Bitrix\Main\Diag\Debug;
use Bitrix\Main\Diag\Helper;
/*Write in file*/
//Debug::writeToFile($variable, $varName, $file);
Debug::writeToFile(['ID' => $ID, 'fields' => $arResult ], null, "log.log");
Debug::dumpToFile(['ID' => $ID, 'fields' => $arResult ], null, "log.log");
/*Time label*/