zpupster Posted March 25, 2015 Posted March 25, 2015 hello, has anyone seen an addon that formats the telephone numbers from the customers database so that when they are called are displayed as (555)555-5555 ? i have been googling and searching for a while now and have not found an answer Quote
Jack_mcs Posted March 25, 2015 Posted March 25, 2015 I doubt that there is an addon for that. It would be something coded per site since there are so many ways to do it. I may be wrong though. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
zpupster Posted March 25, 2015 Author Posted March 25, 2015 this the function i used in invoice.php <?php function format_telephone($phone_number) { $cleaned = preg_replace('/[^[:digit:]]/', '', $phone_number); preg_match('/(\d{3})(\d{3})(\d{4})/', $cleaned, $matches); return "({$matches[1]}) {$matches[2]}-{$matches[3]}"; } ?> called it here: <td class="main"><?php echo format_telephone($order->customer['telephone']); ?></td> this works, but should i put the function in a different area of oscommerce. Roaddoctor 1 Quote
Bob Terveuren Posted March 25, 2015 Posted March 25, 2015 Hi - you should pop that function into includes/functions/general.php and admin/includes/functions/general.php which would allow you to use it anywhere in the site (you'd also need to remove it from invoice.php) An anternative would be to use a jQuery mask on the create_account/account_edit pages so that the number input would hit the database in your desired format or run your function on the database input from create_account (but that kind of assumes that you only ever,ever,ever get US customers and would screw up existing ones - OK so that's a maybe for a new store :-(( ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.