additionally, another problem with phone number display, it changes where the spaces are inserted and groups the numbers incorrectly. e.g. in my country a mobile number is displayed like this:
027 555 1212
but Hivepress, as well as stripping the leading zero, changes where the spaces are and this is the result:
275 551 212
This is not how we display phone numbers and it looks wrong which is very bad for a local directory. How do I fix this?
Phone numbers can have a different number of digits. A landline has 8 but a mobile can have 9, 10 or 11 digits. In phone number display conventions, for landlines, the first 2 digits are grouped together e.g. 03 and for mobiles the first 3 are grouped together e.g 027
Hi,
Thanks for the details.
Please take a look at this thread, where a similar topic was discussed: https://community.hivepress.io/t/help-with-phone-number-formatting/17568
If it doesn’t answer your question, please let us know, and we’ll investigate the issue further.
Hi @kseniiahivepress,
It is the same issue indeed but unfortunately there is no proper solution provided. In that case OP has to resort to a hack to replace “+44” with “0”. I have come up with a different hack to restore the leading zero – I add a zero via css ::before pseudo element. It’s a shame that hacks are needed, but in any case that solves that part of the problem. But the part of the problem that is not solved is the groupings of numbers, i.e. where the spaces are inserted. It would be much better if Hivepress left the originally entered spacing alone rather than change it and get it wrong. Is there a way to override this behavior?
Thanks in advance,
Aidan
Thanks for the additional details.
We’ve identified a bug: when an attribute is restricted to a single country, the country code gets removed from the display [as well as leading zero].
As a quick workaround on your end, you could try entering +44%value% or 0%value% directly into the attribute’s display format field.
We’ve logged this in our bug tracker and will do our best to fix it as soon as possible.
Regarding the formatting, this relies on the script we use, intl-tel-input, which formats numbers based on country. However, it seems to force the international format, which is why the leading zero gets removed.
What about the incorrect number groupings in the output formatting (by incorrect placement of the spaces)? Is there any workaround to fix this?
I see the problem is that intl-tel-input gets the formatting wrong for some New Zealand phone numbers. The correct formatting is described here: https://krispcall.com/phone-numbers/new-zealand-phone-number-format/
NZ mobile number format: 02X XXX XXXX (Domestic) and +64 2X XXX XXXX (International)
For some mobile numbers e.g. 027 4XX XXXX it puts the spaces in the wrong place so the output is
274 XX XXXX instead of:
27 4XX XXXX
(oddly it gets all of the other 27 numbers correct, it’s only if a 4 follows the 27)
I hope you had a relaxing weekend.
I understand the formatting isn’t quite what you’re looking for. Since this functionality relies on a third-party library, we’re a bit limited by how it handles formatting, and we want to make sure any changes we suggest stay compatible with it long-term.
If you’d prefer, we can help you disable the automatic formatting altogether.
If that sounds good to you, feel free to post a request on our community forum, and one of our developers will be happy to help you get it set up: https://community.hivepress.io/.
Thanks for the reply. I think I’ll just live with the formatting issue for now as I have a solution for the bigger part of the issue, the leading issues. If I decide later that I want to fix it, I’ll post on the community forum.