Price slider 4 decimal places

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 week 1 day ago #367322

-- HikaShop version -- : 5.1.6
-- Joomla version -- : 5.3.0
-- PHP version -- : 8.2.28
-- Browser(s) name and version -- : Firefox 1385.0.4
-- Error-message(debug-mod must be tuned on) -- : none

Maybe I did tweak things to much but my cursor price slider, with or without input fields, has 4 decimal places any idea how to change that to 2 decimal places?

Also the decimal separator is a dot (.) not a comma (,) it’s always been this way but can that be changed as well?

If I set the use of the input fields to “No” and change the format for the cursors label it still will display the the dot and not the comma and the decimal places setting does not have any effect.

I did not change anything in administrator/components/com_hikashop/classes/filter.php

For some items I did make some changes (custom field) to display 3 decimal places, but that did not effect the slider decimal places display in Hikashop 4.2.2.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 week 1 day ago #367329

Hi,

Try changing the line:

'<input class="slider_input slider_input_start" id="slider_'.$filter->filter_namekey.'_'.$divName.'_start" value="'.$minVal.'"/>'.
to:
'<input type="number" step="0.01" class="slider_input slider_input_start" id="slider_'.$filter->filter_namekey.'_'.$divName.'_start" value="'.$minVal.'"/>'.
and the line:
'<input class="slider_input slider_input_end" id="slider_'.$filter->filter_namekey.'_'.$divName.'_end" value="'.$maxVal.'"/>'.
to:
'<input type="number" step="0.01" class="slider_input slider_input_end" id="slider_'.$filter->filter_namekey.'_'.$divName.'_end" value="'.$maxVal.'"/>'.
in the file administrator/components/com_hikashop/classes/filter.php
That should help.
Please let us know how it goes. If it works fine, we'll include the change on our end for the next version of HikaShop.

The following user(s) said Thank You: EnerW

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 week 1 day ago #367332

Evening Nicolas,

well that was a quick fix, it does work as intended 2 decimal places and a comma thank you!

The only odd thing that I have left is that if you assign the price filter to a main category without products or prices, or an empty category, it will still show the price slider with a strange price range, but any other filter item like brand or colour is not displayed. The sub categories of that main category will display the price slider and the other filter items like brand and colour correctly, as long as there are items with prices to display.

In the above situation the nouislider.min.css will load after the site template.css so any css override will be lost or you need to use !important (not a fan). The only neat option is to not use the main category and assign each sub category individually to the price filter or use Regular Labs Conditions paid version to block the display of the module to the main category.

On pages with products and prices the nouislider.min.css will load before the site template.css so changes to the display of the slider will be possible.

I think it's the last 1% that will take 99% of the effort to get it perfect ;-)

So thank you again for the fix!

Regards, Rene

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 week 1 day ago #367336

Hi,

Try changing the line:

$cursorMax=1000;
to:
return '';
in the same file. It should hopefully not display the filter when no products is available on the current listing.

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 week 1 day ago #367342

Morning Nicolas,

there are 3 positions with $cursorMax=1000; (line 2592 and lower), I only need to change the first one?

from:

}else{
$cursorMax=1000;
}

to:

}else{
return '';
}

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 week 1 day ago #367344

Yes, that's the one.

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 week 23 hours ago #367352

Did test it early on, not really working. The module will still display with the filter button -> 84.26.189.171:8195/webshop/category/weerstanden

If you click it it will display some unrelated prices.

Not sure if it is worth your time to put more effort in this. In the final version I will not display the empty sub-categories and I can suppress the main category.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 week 22 hours ago #367355

Oeps, did check on mobile view and there it is working with the last modification. I do use the recently viewed and carousel modules in de desktop view but not on mobile.

So it will display the correct filter module on the pages with items and prices but not on pages without.

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 week 19 hours ago #367354

Hi,

Well, I would need to look deeper into it, with backend and FTP access.
If that's not needed for you, we can leave it at that.
We can always revisit the issue in the future if necessary.

The following user(s) said Thank You: EnerW

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
6 days 4 hours ago #367385

Leave it for now, if I use Chromium there are 4 decimal places again but not in Firefox. If I use my phone (Pixel 7) with Firefox 2 decimal places, Google Chrome 4 decimal places and a decimal point.

Thank you for the great support!

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 day 23 hours ago #367453

Afternoon Nicolas,

had some time this morning and did read up on noUiSlider and Wnumb.

If you change line 2744 in filter.php from:

$value = 'parseFloat(values[handle]).toFixed('.(int)$currencies[$currency_id]->currency_locale.')';

to:

$value = 'parseFloat(values[handle]).toFixed(2)';

You get the 2 decimals instead of 4 from Hikashop itself, regardless of the type of browser you use.

As far as I can see code from line 2756 and lower with the formatting settings is not passed on to NoUiSlider and should also be changed, but I did not spend time on that.

else {
$options = '[true, true]';
$format = null;
if(in_array($filter->filter_data, array('price', 'b.product_sort_price'))) {
$format = array(
'mark' => '.',
'thousand' => ' ',
'prefix' => '',
'suffix' => $currency,
'decimals' => '2'
);
I did remove the previous changes to filter.php but I suppose that I need to change filter.php on a Hikashop update.

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 day 19 hours ago #367454

Hi,

If that's the case, then it means the problem is that you configured your currency to have 4 decimals instead of 2 in the System>Currencies menu.
So please check there.

The following user(s) said Thank You: EnerW

Please Log in or Create an account to join the conversation.

  • Posts: 95
  • Thank you received: 6
  • Hikashop Business
1 day 17 hours ago #367464

Evening Nicolas,

yes indeed International fractional digits was set to 4 and Local fractional digits was set to 2. No idea why since it has been this way since version 2.6 and only became a problem for me with 5.1.6 with the changed code in filter.php

In the end there are no changes needed at all, so sorry for wasting your time ;-(

Regards, Rene

Last edit: 1 day 17 hours ago by EnerW.

Please Log in or Create an account to join the conversation.

  • Posts: 83928
  • Thank you received: 13585
  • MODERATOR
1 day 5 hours ago #367465

No worries ! I'm glad it works for you :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum