okopt_client_prices.php 216L cognitive
// a:\Server\OSPanel\domains\_okopt_auth\okopt_client_prices.php
§ block block (L5-L26)
{
static $ids = null;
if ($ids !== null) {
return $ids;
}
$file = __DIR__ . '/okopt_client_price_allow.php';
$ids = [];
if (is_file($file)) {
$loaded = include $file;
if (is_array($loaded)) {
foreach ($loaded as $id) {
$id = (int)$id;
if ($id > 0) {
$ids[] = $id;
}
}
}
}
return $ids;
}
// ... 55 lines omitted
§ function okopt_client_price_rules (L84-L113)
// ... 1 lines omitted
§ block block (L28-L58)
{
static $rules = null;
if ($rules !== null) {
return $rules;
}
$rules = [];
$inn = okopt_client_price_user_inn();
if ($inn === '') {
return $rules;
}
global $DB;
$res = $DB->Query(
"SELECT GOOD_KOD, PRICE_XML_ID, DISCOUNT FROM okopt_client_price WHERE INN='" . $DB->ForSql($inn) . "'"
);
if (!$res) {
return $rules;
}
while ($row = $res->Fetch()) {
$code = trim((string)$row['GOOD_KOD']);
if ($code === '') {
continue;
}
$rules[$code] = [
'PRICE_XML_ID' => strtolower(trim((string)$row['PRICE_XML_ID'])),
'DISCOUNT' => (float)str_replace(',', '.', (string)$row['DISCOUNT']),
];
}
return $rules;
}
// ... 1 lines omitted
§ function okopt_client_price_groups_by_xml (L115-L133)
// ... 1 lines omitted
§ block block (L60-L79)
{
static $map = null;
if ($map !== null) {
return $map;
}
$map = [];
if (!CModule::IncludeModule('catalog')) {
return $map;
}
$res = CCatalogGroup::GetList(['ID' => 'ASC']);
while ($row = $res->Fetch()) {
$xml = strtolower(trim((string)$row['XML_ID']));
if ($xml !== '') {
$map[$xml] = (int)$row['ID'];
}
}
return $map;
}
// ... 1 lines omitted
§ function okopt_client_price_article_by_product($productId (L135-L154)
// ... 23 lines omitted
§ block block (L103-L147)
{
$article = trim((string)$article);
$rule = okopt_client_price_rule($article);
if (!$rule) {
return false;
}
$offerId = (int)($offer['ID'] ?? 0);
if ($offerId <= 0) {
return false;
}
$row = okopt_client_price_row($offerId, $rule['PRICE_XML_ID']);
if (!$row) {
return false;
}
$base = round((float)$row['PRICE'], 2);
$final = okopt_client_price_money($base, $rule['DISCOUNT']);
if ($final < 0) {
$final = 0;
}
if (!isset($offer['ITEM_PRICES'][0]) || !is_array($offer['ITEM_PRICES'][0])) {
$offer['ITEM_PRICES'][0] = [];
}
$offer['ITEM_PRICES'][0]['PRICE'] = $final;
$offer['ITEM_PRICES'][0]['BASE_PRICE'] = $base;
$offer['ITEM_PRICES'][0]['RATIO_PRICE'] = $final;
$offer['ITEM_PRICES'][0]['PRINT_PRICE'] = $final;
$offer['ITEM_PRICES'][0]['PRINT_BASE_PRICE'] = $base;
$offer['ITEM_PRICES'][0]['PRINT_RATIO_PRICE'] = $final;
if (!isset($offer['MIN_PRICE']) || !is_array($offer['MIN_PRICE'])) {
$offer['MIN_PRICE'] = [];
}
$offer['MIN_PRICE']['VALUE'] = $rule['DISCOUNT'] > 0 ? $base : $final;
$offer['MIN_PRICE']['VALUE_VAT'] = $offer['MIN_PRICE']['VALUE'];
$offer['MIN_PRICE']['DISCOUNT_VALUE'] = $final;
$offer['MIN_PRICE']['DISCOUNT_VALUE_VAT'] = $final;
$offer['MIN_PRICE']['DISCOUNT_DIFF'] = $rule['DISCOUNT'] > 0 ? round($base - $final, 2) : 0;
$offer['MIN_PRICE']['PRINT_VALUE'] = $offer['MIN_PRICE']['VALUE'];
$offer['MIN_PRICE']['PRINT_DISCOUNT_VALUE'] = $final;
$offer['OKOPT_CLIENT_PRICE'] = true;
return true;
}
// ... 1 lines omitted
§ function okopt_client_price_apply_item(array (L238-L253)
// ... 1 lines omitted
§ block block (L149-L165)
{
if (!okopt_client_price_display_allowed()) {
return;
}
if (defined('BX_COMP_MANAGED_CACHE') && is_object($GLOBALS['CACHE_MANAGER'])) {
$GLOBALS['CACHE_MANAGER']->RegisterTag('okopt_client_price');
}
if (empty($item['OFFERS'][0]) || !is_array($item['OFFERS'][0])) {
return;
}
$article = okopt_client_price_article_from_item($item);
if (okopt_client_price_apply_offer($item['OFFERS'][0], $article)) {
$item['OKOPT_CLIENT_PRICE'] = true;
}
}
// ... 1 lines omitted
§ function okoptClientPriceOptimal($productId (L255-L303)
§ function okoptClientPriceOptimal($productId (L166-L166)
function okoptClientPriceOptimal($productId, $quantity = 1, $userGroups = [], $renewal = 'N', $prices = [], $siteId = false, $coupons = [])
§ block block (L167-L216)
{
if (!okopt_client_price_allowed() || !CModule::IncludeModule('catalog')) {
return true;
}
$article = okopt_client_price_article_by_product($productId);
$rule = okopt_client_price_rule($article);
if (!$rule) {
return true;
}
$row = okopt_client_price_row($productId, $rule['PRICE_XML_ID']);
if (!$row) {
return true;
}
$base = round((float)$row['PRICE'], 2);
$final = okopt_client_price_money($base, $rule['DISCOUNT']);
if ($final < 0) {
$final = 0;
}
$vat = (float)($row['VAT_RATE'] ?? 0);
$currency = $row['CURRENCY'] ?: 'RUB';
$showBase = $rule['DISCOUNT'] > 0 ? $base : $final;
$discountSum = $rule['DISCOUNT'] > 0 ? round($base - $final, 2) : 0;
return [
'PRICE' => [
'ID' => (int)$row['ID'],
'CATALOG_GROUP_ID' => (int)$row['CATALOG_GROUP_ID'],
'PRICE' => $final,
'CURRENCY' => $currency,
'ELEMENT_IBLOCK_ID' => (int)($row['ELEMENT_IBLOCK_ID'] ?? 0),
'VAT_RATE' => $vat,
'VAT_INCLUDED' => 'Y',
],
'RESULT_PRICE' => [
'BASE_PRICE' => $showBase,
'DISCOUNT_PRICE' => $final,
'UNROUND_BASE_PRICE' => $showBase,
'UNROUND_DISCOUNT_PRICE' => $final,
'CURRENCY' => $currency,
'DISCOUNT' => $discountSum,
'PERCENT' => $rule['DISCOUNT'] > 0 ? $rule['DISCOUNT'] : 0,
'VAT_RATE' => $vat,
'VAT_INCLUDED' => 'Y',
],
'DISCOUNT_LIST' => [],
];
}
7/16 chunks shown (1877 tokens)
[lean-ctx] full source: read "a:\Server\OSPanel\domains\_okopt_auth\okopt_client_prices.php" directly (no MCP) · or ctx_read("a:\Server\OSPanel\domains\_okopt_auth\okopt_client_prices.php", mode="full")
7/15 chunks shown (1781 tokens)
[lean-ctx] full source: read "a:\Server\OSPanel\domains\_okopt_auth\okopt_client_prices.php" directly (no MCP) · or ctx_read("a:\Server\OSPanel\domains\_okopt_auth\okopt_client_prices.php", mode="full")
Бренды
Подождите, прайс-лист генерируется, это может занять несколько минут
×
Заказать звонок
Укажите информацию о покупателе, что бы мы могли с вами связаться
×
Напишите нам
Укажите информацию о покупателе, что бы мы могли с вами связаться
×
Вы успешно зарегистрированы
Поздравляем! Вы успешно зарегистрировались. Теперь вы можете
перейти в свой профиль , чтобы настроить аккаунт, или ознакомиться с нашим
каталогом и продукцией . Мы рады видеть вас в нашей команде!