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?
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)
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.
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:
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