How to hide commas for numbers attribute on listing?

We want to add (numbers) attribute for vehicle mileage with (numbers range) search/filter as an attribute for vehicles listed. User would have drop down select option for vehicle mileage showing years (2022, 2021, 2020, etc) when they add vehicle listing.

On the front end, we do not want commas to be included in the vehicle year. So for example, right now if user enters 2007 for the year, the front end shows Year: 2,007 which is not want we want. Can anyone explain the correct way to do this with attributes so that commas will not appear for certain number attributes?

Thank you!

I’m requesting the same thing. Trying to do it for boats and 2003 boat comes up as 2,003. Thanks.

1 Like

Hello, I have been discussing the same with the developers on the Wordpress support page. Was redirected to this community page from there. I had been facing the same issue with my website and this is what what solved my problem:

Blockquote Sorry if it’s confusing, there may be incompatible edit/search types. If it’s a selectable attribute, then its search type can’t be set to the Number Range, because selectable attributes are registered as custom taxonomies, not numeric values. I recommend switching the edit type to Number and limiting values (e.g. from 1990 to 2022). Then users will be able to set a valid year and it’ll be searchable via the number range filter. >/Blockquote (IDK why the quotes are not working)

Blockquote Please use the Text number instead (if you don’t want to format the value as a number), with a custom Regex pattern https://hivepress.io/support/topic/remove-comma-from-number-attribute/#post-18415 > Blockquote

This step allows the user to input the year and takes out the commas but, for me, it does away with the range setting on the YEAR attribute. This is my current problem and I am posting here so that we all can learn what the solution to this can be.

Cheers!

Yes, the best way to do this in the current version is using a Text field because the Number value will always be formatted as a number. You can set this Regex patter for the Text field to restrict values:

(19|20)[0-9]{2}

This should allow 1900-2099 values only.

Thank you!

I have a related question. I want the commas to appear for the Price attribute in the Filter as well as the user input Price when filling the ADD LISTING form. Currently the commas do appear when the price for the listing is displayed but not in the filter or add listings form. How do I do that?

Unfortunately, there’s no such option, the number is formatted for display only, when you edit it there’s just a number. We use the default “number” field type implemented by the browser so some browsers may add formatting, but I can’t say for sure <input type="number"> - HTML: HyperText Markup Language | MDN

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.