Hey,
I hope you had a nice weekend! ![]()
I was previously using the snippet I shared in this topic to provide a better experience of how UK mobile numbers are displayed.
However, since the telephone library was updated, I’ve struggled to get the phone numbers to appear on the front-end as I’d like.
For clarify, my HivePress phone attribute settings are set to UK as the default and only country.
‘+44’ is the international dialing code for UK numbers.
When using the international code, we drop the leading ‘0’ from our numbers.
e.g. 07778983544 becomes +447778983544
When completing a user’s profile or adding listing details, no matter if I enter the 10 or 11 digit number, the resulting number that’s being displayed on the front-end of listing is missing the leading ‘0’. There’s also a space added to the middle of the number.
e.g. I enter 07778983544 and on the actual listing I see ‘7778 983544’
Whether or not I add the space in the backend doesn’t seem to matter, it gets trimmed during validation.
I’ve tried using various AI bots to try and provide a working solution, but sadly, none of them are working as intended.
The part that irritates me the most and what I’m trying to fix is the loss of the leading ‘0’ in the resulting number that’s shown on the front-end. Even if the +44 part showed instead of the missing ‘0’, that would be better.
In any case, when I click on the number to dial it, the ‘0’ is included in the “tel:” link and what’s displayed on my phone.
I’ve tried clearing my site cache and using an incognito browser window in case caching was the issue, but this doesn’t seem to help.
When I am trialing new code snippets, I occasionally briefly see one version before the page fully loads and the formatted version missing the leading ‘0’ takes its place.
If it makes any difference I have the listing/vendor attribute synced, and I’'m using the attribute slug name ‘phone_number’.
Cheers,
Chris ![]()