[Skip to main content](#vessel-content)

#   How to change telephone number format.

##

- **[FedHillt](/forum/user/40648-fedhillt "View FedHillt's Profile")**
- [![FedHillt's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/40648-fedhillt "View FedHillt's Profile") Topic Author
- [ Offline](/forum/user/40648-fedhillt)

Less More

- Posts: 8
- Thank you received: 1
-
-

10 years 8 months ago [\#231927](#231927) by [FedHillt](/forum/user/40648-fedhillt "View FedHillt's Profile")  *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#231927 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")* was created by *[FedHillt](/forum/user/40648-fedhillt "View FedHillt's Profile")*

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.6.18

Hi,

I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.

Right now the numbers on the invoice show up like this. 15555555555

I would like it to show up like this. 1-555-555-5555

or like this. 1 555 555 5555.

Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.

Thanks for your time,
Tim

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

10 years 8 months ago [\#231938](#231938) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#231938 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hi,

For that, you can replace the line: Code:

&lt;?php echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?&gt;

by: Code:

&lt;?php function localize_us_number($phone) { $numbers_only = preg_replace("/[^\d]/", "", $phone); return preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $numbers_only); } $address = $this-&gt;params-&gt;get('address'); echo JText::sprintf('TELEPHONE_IN_ADDRESS',localize_us_number($address-&gt;address_telephone)); ?&gt;

in the file "address_template" for both your frontend and your backend templates.

The following user(s) said Thank You: [tonp](/forum/user/40437-tonp "View tonp's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")**
- [![mikehermary's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35673-mikehermary "View mikehermary's Profile")
- [ Offline](/forum/user/35673-mikehermary)

Less More

- Posts: 127
- Thank you received: 1
-
-

10 years 6 months ago [\#238831](#238831) by [mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")  Replied by *[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#238831 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hello,

I have tried using this function in the address_template file, but it breaks the page. I have included the code I have in the file below. Could you let me know what is going wrong? Thanks.
Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.6.2 * @author hikashop.com * @copyright (C) 2010-2016 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt; &lt;span&gt;{address_title} {address_firstname} {address_lastname}&lt;/span&gt; &lt;span&gt;{address_street}&lt;/span&gt; &lt;span&gt;{address_city}, {address_state} {address_post_code}&lt;/span&gt; &lt;?php function localize_us_number($phone) { $numbers_only = preg_replace("/[^\d]/", "", $phone); return preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $numbers_only); } $address = $this-&gt;params-&gt;get('address'); ?&gt; &lt;span&gt;&lt;?php echo JText::sprintf('TELEPHONE_IN_ADDRESS',localize_us_number($address-&gt;address_telephone)); ?&gt;&lt;/span&gt;

Mike

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

10 years 6 months ago [\#238838](#238838) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#238838 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hi,

What error do you get when you do that with the "error reporting" setting of the Joomla configuration activated ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")**
- [![mikehermary's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35673-mikehermary "View mikehermary's Profile")
- [ Offline](/forum/user/35673-mikehermary)

Less More

- Posts: 127
- Thank you received: 1
-
-

10 years 6 months ago [\#238867](#238867) by [mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")  Replied by *[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#238867 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hello,

I have enabled maximum error reporting in Joomla, but no errors are displayed. The HTML is broken and the CSS is not even loaded. I have included a screenshot show the rendered page and included the outputted HTML from the developer tools in Safari below. The function seems to be working, as the dashes are being added to the phone number, but something is breaking the page. I have disabled certain template overrides and think I have narrowed it down to the address_template.php file with the extra function that is the culprit. With it disabled the page works with no issues. It is either the file itself or how the code interacts with other files.
Code:

&lt;div id="hikashop_checkout_page" class="hikashop_checkout_page hikashop_checkout_page_step2"&gt; &lt;form action="/book-store/checkout/task-step/step-3" method="post" name="hikashop_checkout_form" enctype="multipart/form-data" onsubmit="if('function' == typeof(hikashopSubmitForm)) { hikashopSubmitForm('hikashop_checkout_form'); return false; } else { return true; }"&gt; &lt;div id="hikashop_checkout_address" class="hikashop_checkout_address"&gt; &lt;div id="hikashop_checkout_address_left_part" class="hikashop_checkout_address_left_part"&gt; &lt;fieldset class="hika_address_field" id="hikashop_checkout_billing_address"&gt; &lt;legend&gt;Billing Address&lt;/legend&gt; &lt;div class="hikashop_checkout_address_choice_wrap selected"&gt; &lt;label for="hikashop_checkout_billing_address_radio_1972" class="hikashop_checkout_address_choice"&gt;&lt;input id="hikashop_checkout_billing_address_radio_1972" class="hikashop_checkout_billing_address_radio" type="radio" name="hikashop_address_billing" value="1972" checked="checked" /&gt;&lt;span&gt;Checkout with this address&lt;/span&gt;&lt;/label&gt; &lt;label for="hikashop_checkout_billing_address_radio_1972" style="cursor:pointer;"&gt; &lt;div class="hikashop_checkout_billing_address_info"&gt; &lt;span&gt; MT Help&lt;/span&gt; &lt;span&gt;4567 Some Place Street&lt;/span&gt; &lt;span&gt;Kerikeri, Alberta 3246&lt;/span&gt; &lt;span&gt;Telephone: 403-123-4567&lt;/span&gt; &lt;/div&gt; &lt;/label&gt; &lt;div class="hikashop_checkout_billing_address_buttons"&gt; &lt;a id="hikashop_checkout_billing_address_edit_1972" title="Edit" class="hikashop_checkout_billing_address_edit btn-blue btn-small modal" href="/book-store/checkout/address/edit/redirect-checkout/address_id-1972/step-2/type-billing/tmpl-component" onclick="return hikashopEditAddress(this,1,false);"&gt; Edit &lt;/a&gt; &lt;a onclick="if(!confirm('Are you sure you want to delete this address ?')){return false;}else{return true;}" title="Remove" class="hikashop_checkout_billing_address_delete btn-red btn-small" href="/book-store/checkout/checkout/deleteaddress/step-2/redirect-checkout/address_id-1972/c98febf6a5aa9f629c9ce5ab3a428c1b-1"&gt; Remove&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="hikashop_checkout_address_choice_wrap"&gt; &lt;label for="hikashop_checkout_billing_address_radio_1974" class="hikashop_checkout_address_choice"&gt;&lt;input id="hikashop_checkout_billing_address_radio_1974" class="hikashop_checkout_billing_address_radio" type="radio" name="hikashop_address_billing" value="1974" onclick="this.form.submit(); return false;" /&gt;&lt;span&gt;Checkout with this address&lt;/span&gt;&lt;/label&gt; &lt;label for="hikashop_checkout_billing_address_radio_1974" style="cursor:pointer;"&gt; &lt;div class="hikashop_checkout_billing_address_info"&gt;

Mike

- [ ![rendered&#95;html&#95;no&#95;errors&#95;displayed.png](/forum/attachment/31162) ](/forum/attachment/31162 "...&#95;displayed.png") [ ](/forum/attachment/31162?download=1 "...&#95;displayed.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

10 years 6 months ago -  10 years 6 months ago [\#238921](#238921) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#238921 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hi,

It's probably because there is a function and thus the system tries to load it several times and it crashes.
So just do it without a function.
Instead of: Code:

&lt;?php function localize_us_number($phone) { $numbers_only = preg_replace("/[^\d]/", "", $phone); return preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $numbers_only); } $address = $this-&gt;params-&gt;get('address'); echo JText::sprintf('TELEPHONE_IN_ADDRESS',localize_us_number($address-&gt;address_telephone)); ?&gt;

do: Code:

&lt;?php $address = $this-&gt;params-&gt;get('address'); echo JText::sprintf('TELEPHONE_IN_ADDRESS',preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", preg_replace("/[^\d]/", "", $address-&gt;address_telephone))); ?&gt;

Last edit: 10 years 6 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

The following user(s) said Thank You: [leitzdesign](/forum/user/39770-leitzdesign "View leitzdesign's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")**
- [![mikehermary's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35673-mikehermary "View mikehermary's Profile")
- [ Offline](/forum/user/35673-mikehermary)

Less More

- Posts: 127
- Thank you received: 1
-
-

10 years 6 months ago [\#238957](#238957) by [mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")  Replied by *[mikehermary](/forum/user/35673-mikehermary "View mikehermary's Profile")* on topic *[How to change telephone number format.](/forum/35-orders-management/882751-how-to-change-telephone-number-format#238957 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.6.18  Hi,  I would like to know how to change the format of the telephone numbers. More specifically, I would like to add dashes, or at the very least add space between the numbers on the order invoice.  Right now the numbers on the invoice show up like this. 15555555555  I would like it to show up like this. 1-555-555-5555  or like this. 1 555 555 5555.  Is there anyway this can be done? I've already tried looking through the PHP address files, but I couldn’t find any place where I would be able to edit the format.  Thanks for your time, Tim")*

Hello,

Thanks, that worked perfectly.

Mike

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4Mjc1MS1ob3ctdG8tY2hhbmdlLXRlbGVwaG9uZS1udW1iZXItZm9ybWF0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.077 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
