Easier phone number formatting
under review
Tim Mackey
Currently, formatting a phone number into a human readable format takes quite a bit of work. You have to strip out any non-digit characters, and then split the remaining digits into individual characters and output them one by one. It’s also prone to errors, as you can only support one phone number format this way.
The
e164
filter is useful for getting the phone number into a standard machine-readable format, but it’s not great for user-facing tasks like invoice generation. Implementing something like number_to_phone in Rails would make this kind of user-friendly formatting far easier.C
Charles Akben-Marchand
Matt Sodomsky In another system I use, I configured roughly the following logic for phone numbers (the vast majority of which I receive are North American format):
- Strip down to numerals and letters (e.g. "x", "ext")
- Omit leading 1
- If 7 or 10 numerals in the string (or 7/10 numerals before the first letter), format as 123-4567 or 123-456-7890
- If there is a letter followed by more numerals, append those numerals to the above with "x12345"
- If not 7 or 10 numerals in the string/before the first letter, leave the original string as entered, prepending with a + if one is not already present, and back away slowly. ;)
Dominik Diemer
Hey Team,
we also need that!
At the moment, we use the task that copies the telephone number in the correct field of shopify. But it is not taking into account the telephone prefixes which can be +49 or 0049, and if the customer does not include a prefix it's always the prefix of the Shops country not the prefix of the customers country.
We need a task, which recognizes the customer's country and then updates it accordingly and brings it into a machine readable format.
In my view, this is very interesting for many SMBs from Europe.
They often do business in 3-4 countries. We have 4 liscenses of mechanic running at the moment.
B. N
International phone number user here! Voting for this to bulk update/edit all phone numbers to remove spaces.
Matt Sodomsky
under review
Matt Sodomsky
@matt-scheurich- how would you want this to work for international phone numbers?