Answer the question
In order to leave comments, you need to log in
How to display the price after 2 custom properties in a smart filter?
The site uses a standard catalog.smart.filter component with a .default template. By design, you need to display the HIT and ACTIONS properties before choosing a price prntscr.com/fv4qks
The template contains a condition for displaying a price at the beginning.
I tried to specify the output of the array, but it turns out that it is output 2 times at the beginning and by sort level.
Filter pattern:
<div class="row full-row">
<?foreach($arResult["ITEMS"] as $key=>$arItem)//prices
{
$key = $arItem["ENCODED_ID"];
if(isset($arItem["PRICE"])):
if ($arItem["VALUES"]["MAX"]["VALUE"] - $arItem["VALUES"]["MIN"]["VALUE"] <= 0)
continue;
$precision = 2;
if (Bitrix\Main\Loader::includeModule("currency"))
{
$res = CCurrencyLang::GetFormatDescription($arItem["VALUES"]["MIN"]["CURRENCY"]);
$precision = $res['DECIMALS'];
}
?>
<div class="<?if ($arParams["FILTER_VIEW_MODE"] == "HORIZONTAL"):?>col-sm-6 col-md-4<?else:?>col-lg-12<?endif?> bx-filter-parameters-box bx-active">
<span class="bx-filter-container-modef"></span>
<div class="bx-filter-parameters-box-title" onclick="smartFilter.hideFilterProps(this)"><span><?=$arItem["NAME"]?> <i data-role="prop_angle" class="fa fa-angle-<?if ($arItem["DISPLAY_EXPANDED"]== "Y"):?>up<?else:?>down<?endif?>"></i></span></div>
<div class="bx-filter-block" data-role="bx_filter_block">
<div class="row bx-filter-parameters-box-container">
<div class="col-xs-6 bx-filter-parameters-box-container-block bx-left">
<i class="bx-ft-sub"><?=GetMessage("CT_BCSF_FILTER_FROM")?></i>
<div class="bx-filter-input-container">
<input
class="min-price"
type="text"
name="<?echo $arItem["VALUES"]["MIN"]["CONTROL_NAME"]?>"
id="<?echo $arItem["VALUES"]["MIN"]["CONTROL_ID"]?>"
value="<?echo $arItem["VALUES"]["MIN"]["HTML_VALUE"]?>"
size="5"
onkeyup="smartFilter.keyup(this)"
placeholder="от"
/>
</div>
</div>
<div class="col-xs-6 bx-filter-parameters-box-container-block bx-right">
<i class="bx-ft-sub"><?=GetMessage("CT_BCSF_FILTER_TO")?></i>
<div class="bx-filter-input-container">
<input
class="max-price"
type="text"
name="<?echo $arItem["VALUES"]["MAX"]["CONTROL_NAME"]?>"
id="<?echo $arItem["VALUES"]["MAX"]["CONTROL_ID"]?>"
value="<?echo $arItem["VALUES"]["MAX"]["HTML_VALUE"]?>"
size="5"
onkeyup="smartFilter.keyup(this)"
placeholder="до"
/>
</div>
</div>
<div class="col-xs-10 col-xs-offset-1 bx-ui-slider-track-container">
<div class="bx-ui-slider-track" id="drag_track_<?=$key?>">
<?
$precision = $arItem["DECIMALS"]? $arItem["DECIMALS"]: 0;
$step = ($arItem["VALUES"]["MAX"]["VALUE"] - $arItem["VALUES"]["MIN"]["VALUE"]) / 4;
$price1 = number_format($arItem["VALUES"]["MIN"]["VALUE"], $precision, ".", "");
$price2 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step, $precision, ".", "");
$price3 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step * 2, $precision, ".", "");
$price4 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step * 3, $precision, ".", "");
$price5 = number_format($arItem["VALUES"]["MAX"]["VALUE"], $precision, ".", "");
?>
<div class="bx-ui-slider-part p1"><span><?=$price1?></span></div>
<div class="bx-ui-slider-part p2"><span><?=$price2?></span></div>
<div class="bx-ui-slider-part p3"><span><?=$price3?></span></div>
<div class="bx-ui-slider-part p4"><span><?=$price4?></span></div>
<div class="bx-ui-slider-part p5"><span><?=$price5?></span></div>
<div class="bx-ui-slider-pricebar-vd" style="left: 0;right: 0;" id="colorUnavailableActive_<?=$key?>"></div>
<div class="bx-ui-slider-pricebar-vn" style="left: 0;right: 0;" id="colorAvailableInactive_<?=$key?>"></div>
<div class="bx-ui-slider-pricebar-v" style="left: 0;right: 0;" id="colorAvailableActive_<?=$key?>"></div>
<div class="bx-ui-slider-range" id="drag_tracker_<?=$key?>" style="left: 0%; right: 0%;">
<a class="bx-ui-slider-handle left" style="left:0;" href="javascript:void(0)" id="left_slider_<?=$key?>"></a>
<a class="bx-ui-slider-handle right" style="right:0;" href="javascript:void(0)" id="right_slider_<?=$key?>"></a>
</div>
</div>
</div>
</div>
</div>
</div>
<?
$arJsParams = array(
"leftSlider" => 'left_slider_'.$key,
"rightSlider" => 'right_slider_'.$key,
"tracker" => "drag_tracker_".$key,
"trackerWrap" => "drag_track_".$key,
"minInputId" => $arItem["VALUES"]["MIN"]["CONTROL_ID"],
"maxInputId" => $arItem["VALUES"]["MAX"]["CONTROL_ID"],
"minPrice" => $arItem["VALUES"]["MIN"]["VALUE"],
"maxPrice" => $arItem["VALUES"]["MAX"]["VALUE"],
"curMinPrice" => $arItem["VALUES"]["MIN"]["HTML_VALUE"],
"curMaxPrice" => $arItem["VALUES"]["MAX"]["HTML_VALUE"],
"fltMinPrice" => intval($arItem["VALUES"]["MIN"]["FILTERED_VALUE"]) ? $arItem["VALUES"]["MIN"]["FILTERED_VALUE"] : $arItem["VALUES"]["MIN"]["VALUE"] ,
"fltMaxPrice" => intval($arItem["VALUES"]["MAX"]["FILTERED_VALUE"]) ? $arItem["VALUES"]["MAX"]["FILTERED_VALUE"] : $arItem["VALUES"]["MAX"]["VALUE"],
"precision" => $precision,
"colorUnavailableActive" => 'colorUnavailableActive_'.$key,
"colorAvailableActive" => 'colorAvailableActive_'.$key,
"colorAvailableInactive" => 'colorAvailableInactive_'.$key,
);
?>
<script type="text/javascript">
BX.ready(function(){
window['trackBar<?=$key?>'] = new BX.Iblock.SmartFilter(<?=CUtil::PhpToJSObject($arJsParams)?>);
});
</script>
<?endif;
}
//not prices
foreach($arResult["ITEMS"] as $key=>$arItem)
{
if(
empty($arItem["VALUES"])
|| isset($arItem["PRICE"])
)
continue;
if (
$arItem["DISPLAY_TYPE"] == "A"
&& (
$arItem["VALUES"]["MAX"]["VALUE"] - $arItem["VALUES"]["MIN"]["VALUE"] <= 0
)
)
continue;
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question