N
N
neonox2014-05-07 11:59:11
PHP
neonox, 2014-05-07 11:59:11

How to display the price with spaces in Bitrix?

Good day, colleagues!
Please help me understand the situation.
There is a site with a filter. As you can see, the price is indicated not very user-friendly. How to make a division like this 500,000 or 1,000,000?
This is displayed, as I understand it, with this code

The code
<form action="#">
  <div class="ye_filter" id="ys_filter_bitronic">
  <?if(count($arrN) > 0):?>
  <?foreach($arrN as $arItem):?>

  <? if($arItem['VALUES']['MIN'] == $arItem['VALUES']['MAX']) continue; ?>
  <?		
    preg_match_all("| name=\"(.*)\" |U", $arItem["INPUT"], $names);
    $min_name = $names[1][0];
    $max_name = $names[1][1];
  ?>
              <script type="text/javascript">
              $(function(){
              
                $("#<?=$arItem['CODE']?>-min").attr('value', <?=$arItem['VALUES']['MIN_VALUE']?$arItem['VALUES']['MIN_VALUE']:$arItem['VALUES']['MIN'];?>);
                $("#<?=$arItem['CODE']?>-max").attr('value', <?=$arItem['VALUES']['MAX_VALUE']?$arItem['VALUES']['MAX_VALUE']:$arItem['VALUES']['MAX'];?>);
              
                $("#limit-<?=$arItem['CODE']?>").slider({
                  range: true,
                  min: <?=$arItem['VALUES']['MIN']?$arItem['VALUES']['MIN']:0;?>,
                  max:  <?=$arItem['VALUES']['MAX']?$arItem['VALUES']['MAX']:10000;?>,
                  <?if ($arItem["IS_FLOAT"] == 1):?>
                    step: 0.1,
                  <?endif;?>
                  values: [ <?=$arItem['VALUES']['MIN_VALUE']?$arItem['VALUES']['MIN_VALUE']:$arItem['VALUES']['MIN'];?>, <?=$arItem['VALUES']['MAX_VALUE']?$arItem['VALUES']['MAX_VALUE']:$arItem['VALUES']['MAX'];?> ],
                  slide: function(event, ui) {
                    $("#<?=$arItem['CODE']?>-min").attr('value', ui.values[0]);
                    $("#<?=$arItem['CODE']?>-max").attr('value', ui.values[1]);
                    $("#left-<?=$arItem['CODE']?>").html(ui.values[0]);
                    $("#right-<?=$arItem['CODE']?>").html(ui.values[1]);
                  }
                });
              });
              </script>
    <div class="ye_price">
      <div class="ye_price_left">
        <span class="ye_tit"><?=$arItem["NAME"]?>:</span>
        <span><?=GetMessage('OT');?></span> <input value="<?=$arItem['VALUES']['MIN_VALUE']?$arItem['VALUES']['MIN_VALUE']:$arItem['VALUES']['MIN'];?>" name="<?=$min_name?>" type="text" class="txt" id="<?=$arItem[CODE]?>-min" />
      </div>
      <div class="ye_price_right"><span><?=GetMessage('DO');?></span> <input name="<?=$max_name?>" value="<?=$arItem['VALUES']['MAX_VALUE']?$arItem['VALUES']['MAX_VALUE']:$arItem['VALUES']['MAX'];?>" type="text" class="txt" id="<?=$arItem['CODE']?>-max" /></div>
      <div class="ye_price_content">
        <span class="ye_from"><?=$arItem['VALUES']['MIN']?$arItem['VALUES']['MIN']:0;?></span>
        <span class="ye_to"><?=$arItem['VALUES']['MAX']?$arItem['VALUES']['MAX']:10000;?></span>
        <div class="ye_limit" id="limit-<?=$arItem['CODE']?>"></div>
      </div>

    
    </div>


Tried to play with number_format, but got no result. The indent in the numbers does not appear.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Lobanov, 2014-05-07
@neonox

Even if you initially display the number in a formatted form using Bitrix, changing it with the slider you will get an unformatted number again.
Also, the slider script cannot work with numbers with a space - you can see for yourself by entering the number 10,000, for example. The slider just disappears.
Accordingly, all this pulls us further:
1. It is necessary to redo the work of the slider script to:
a. Checking for a number or converting a string to a number
b. Converting the result to a formatted string (with spaces)
2. You need to make sure that the filter will work - now it does not work, because as far as I understand, it counts 10,000 as 10 (it filters the results only by 1 rub.)
If Bitrix can deal with the second point on its own (this is provided that the output in a formatted form will occur by means of Bitrix, as far as I know the format is there only for price, that is, not your case), then the first point will still have to be decided by yourself.
And if you are talking about the result of the filter, that is, a list of goods with prices, then this is just the case to be solved, see dev.1c-bitrix.ru/api_help/catalog/price.php#Format...

G
Glomen, 2014-05-07
@Glomen

Look in $arResult for all possible prices, in general there is a price with formatting there and it will contain the price of 1,000,000, well, or how the price formatting is set in the settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question