Forums / Templates, Stylesheets, Page Layout / How To: Add Phone Number field to Contact Us

How To: Add Phone Number field to Contact Us

Locked

Views: 14,553

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
28 Sep 2006, 7:05 PM
#1
flakrat avatar

flakrat

New Zenner

Join Date:
Apr 2005
Posts:
74
Plugin Contributions:
0

How To: Add Phone Number field to Contact Us

The following documents (rightly or wrongly) how I added the Phone Number field to the Contact Us form.

I got the basic steps from a thread in the support archives, however they didn't work for 1.3.5 and required some additional customization.

The following will:
a) Add the Phone Number field to the contact us page
b) Fill in the phone number field if the user is logged in and has a phone number in their account
c) print the phone number in the email

These are the files I edited
./includes/languages/english/MYTEMPLATE/contact_us.php
./includes/languages/english/MYTEMPLATE/email_extras.php
./includes/modules/pages/contact_us/header_php.php
./includes/templates/MYTEMPLATE/templates/tpl_contact_us_default.php
./admin/includes/languages/english/email_extras.php

File 1: Insert the following lines
./includes/languages/english/MYTEMPLATE/contact_us.php

define('ENTRY_PHONE', 'Phone Number:');
define('ENTRY_EMAIL_PHONE_CHECK_ERROR','You must enter your phone number. Please try again.');

File 2: Insert the following line
./includes/languages/english/MYTEMPLATE/email_extras.php

define('OFFICE_PHONE','<strong>Phone:</strong>');

File 3:
./includes/modules/pages/contact_us/header_php.php
Add this to around line 15

$phone = zen_db_prepare_input($_POST['phonenumber']);
Modify the sql line around line 24
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id, customers_telephone
Insert this line around line 32
$customer_phone= $check_customer->fields['customers_telephone'];
...
} else {
...
$customer_phone='Not logged in';
Around line 50, modify the extra_info and text_message to look like
$extra_info = email_collect_extra_info($name, $email_address, $customer_name, $customer_email, $customer_phone);
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_PHONE . "\t" . $phone . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
Around line 63, change html_msg to look like
$html_msg['CONTACT_US_OFFICE_FROM'] = OFFICE_FROM . ' ' . $name . '<br />' . OFFICE_PHONE . ' ' . $phone . '<br />' . OFFICE_EMAIL . '(' . $email_address . ')';
Around line 78, insert the code to test whether or not the phone number field has text in it
if (empty($phone)) {
$messageStack->add('contact', ENTRY_EMAIL_PHONE_CHECK_ERROR);
}
Around line 90, change the sql statement
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id, customers_telephone
A few lines down, insert
$phone= $check_customer->fields['customers_telephone'];

File 4: Insert the following in between the contactname and email-address field definitions
./includes/templates/MYTEMPLATE/templates/tpl_contact_us_default.php

<label class="inputLabel" for="phonenumber"><?php echo ENTRY_PHONE; ?></label>

<?php echo zen_draw_input_field('phonenumber', $phone, ' size="40" id="phonenumber"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" />

File 5: Insert the following define
./admin/includes/languages/english/email_extras.php

define('OFFICE_PHONE','Phone:');

Hope this helps someone (or me when I forget how I did it :-)

13 Oct 2006, 8:34 PM
#2
kgmmusic avatar

kgmmusic

New Zenner

Join Date:
Nov 2005
Posts:
76
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Thanks a million for the clear and concise instructions, it worked like a charm!!!

17 Oct 2006, 9:05 AM
#3
markov avatar

markov

New Zenner

Join Date:
Sep 2006
Posts:
32
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Hi flakrat
Thanks for this piece of information - it worked a treat. I used it change my Contact Us page and also to change my Ask A Question module. Fantastic.
I am no PHP coder - but it all worked fine - so I was chuffed.

I am hoping if someone can guide me on also adding a multi-select dropdown box (ie a select box) rather than just a text field. I have tried mucking around but I can't work out the correct code - can anyone give me a hint here -

this is the html code -

<form name="form1" method="post" action=""> <p> How did you find out about us? <select name="select"> <option value="Yellow Pages Online">Yellow Pages Online</option> <option value="Advertising magazine">Advertising magazine</option> <option value="Advertising cars">Advertising cars</option> <option value="Architect or Designer">Architect or Designer</option> <option value="Internet">Internet</option> <option value="Referered">Referered</option> <option value="Furniture from Installation">Furniture from Installation</option> <option value="Other">Other</option> </select> </p> </form>
17 Oct 2006, 10:26 AM
#4
ryk avatar

ryk

Totally Zenned

Join Date:
Oct 2004
Location:
Southport, UK
Posts:
3,644
Plugin Contributions:
6

Re: How To: Add Phone Number field to Contact Us

I hope you don't mind flakrat, but I've packaged this up as a mod and submitted it to the downloads section with the following comment attached to the description...

Initially posted in a thread by flakrat, I have simply packaged up the relevant modified files to allow easy installation, and can take no credit whatsoever for the coding.

I should have asked first, but it only just occurred to me as I hit the submit button!

Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !

9 Nov 2006, 12:16 PM
#5
gruntre69 avatar

gruntre69

Zen Follower

Join Date:
Aug 2005
Location:
Australia
Posts:
103
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Hey thanks Flakrat, this was a great help.

I have found a very small problem though and I am not sure whether it is just with my install.

I only get the error message about an empty phone field if there is another message stack message being displayed. If the empty phone is the only error the form is transmitted with the empty phone field.

Quite strange but no big deal, I am happy that I now have the phone field regardless of whether it is mandatory or not.

Just an observation.

Cheers

Cheers all,

Gruntre69

WayCool
Zen is Way Cool too!

29 Dec 2006, 9:33 PM
#6
creativewitch avatar

creativewitch

New Zenner

Join Date:
Nov 2004
Posts:
43
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Thanks for this. I am getting an error:

Parse error: syntax error, unexpected '.' in /home/curvycat/public_html/store/includes/modules/pages/contact_us/header_php.php on line 33

Does anyone know what I did wrong?

29 Dec 2006, 11:12 PM
#7
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: How To: Add Phone Number field to Contact Us

It looks like you litterally added "..." here:

$customer_phone= $check_customer->fields['customers_telephone'];
...
} else {
...
$customer_phone='Not logged in';
```while flarat probably meant that that there will already be some lines of code there, that you need to add the given lines of code before/after.
20 Apr 2007, 4:21 PM
#8
aspagarino avatar

aspagarino

New Zenner

Join Date:
Mar 2007
Location:
San Diego
Posts:
6
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

gruntre69:

Hey thanks Flakrat, this was a great help.

I have found a very small problem though and I am not sure whether it is just with my install.

I only get the error message about an empty phone field if there is another message stack message being displayed. If the empty phone is the only error the form is transmitted with the empty phone field.

Quite strange but no big deal, I am happy that I now have the phone field regardless of whether it is mandatory or not.

Just an observation.

Cheers

The solution :clap:for the small problem phone number field verification ( error when only the phone field is left blank)

Around line 22 add the phone to the if statement:

 if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone)) 
20 Apr 2007, 4:57 PM
#9
aspagarino avatar

aspagarino

New Zenner

Join Date:
Mar 2007
Location:
San Diego
Posts:
6
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

I am sorry... I forgot to mention on my last post on File 3:
./includes/modules/pages/contact_us/header_php.php
Add this to around line 22

if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone)) {
24 May 2007, 11:48 AM
#10
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Not sure what I'm doing wrong but I downloaded the mod and followed step by step but the Add Phone Number field isn't showing. Am I missing something perhaps?

Thanks
http://www.foxxydiva.com/fashions

11 Jul 2007, 10:14 AM
#11
stenrique avatar

stenrique

Zen Follower

Join Date:
Apr 2005
Posts:
355
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Has anybody been able to enforce a min. char. (the same checking feature as at the account creation page) for this new "phone no." field?

15 Oct 2007, 11:28 PM
#12
duckbill avatar

duckbill

New Zenner

Join Date:
May 2007
Location:
Lake Superior
Posts:
27
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

After spending hours wading through pages of (possibly outdated) instructions on how to customize or add fields to the 'Contact Us' page for Zencart version 1.3.7. >THIS ONE ACTUALLY WORKED!!!< THANK YOU FLAKRAT!:thumbsup:


21 Aug 2008, 3:06 AM
#13
j_kins avatar

j_kins

New Zenner

Join Date:
Jul 2008
Posts:
2
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Hi, this contrubition worked a treat!

The only thing that is not working for me is on my Contact Us page - the Phone Number entry has PHONE_ENTRY instead of Phone:

Everything else seems to be working fine.

I have double checked the code and cannot find where I have gone wrong. If anyone has any suggestions, they would be very much appreciated. I am pretty new to this and apologise if this is a really easy fix.

My site link is

http://www.wholesalethreads.com.au/index.php?main_page=contact_us

9 Oct 2008, 6:14 AM
#14
renaissanceart avatar

renaissanceart

New Zenner

Join Date:
Oct 2007
Posts:
65
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

i dont have the first 2 files??? :cry:

9 Oct 2008, 6:32 AM
#15
renaissanceart avatar

renaissanceart

New Zenner

Join Date:
Oct 2007
Posts:
65
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

Trying this on 1.3.8

Out of the 5 files to modify i only have file 3 & 5. I attempted the mod on those 2 without any luck :oops:

Any suggestions ?

12 Dec 2008, 2:31 AM
#16
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: How To: Add Phone Number field to Contact Us

renaissanceart:

Trying this on 1.3.8

Out of the 5 files to modify i only have file 3 & 5. I attempted the mod on those 2 without any luck :oops:

Any suggestions ?

You may have found the answer yourself by now, but, just in case...

You'll find contact_us.php and email_extras.php in the includes/languages/english folder. They'd only be in your template folder if you put them there yourself. It is recommended that you put the altered files in your includes/languages/english/MYTEMPLATE folder rather than changing the ones that are in the default folder. Of course, change "MYTEMPLATE" to the actual name of your template. If you are using the classic template, put them there.

tpl_contact_us_default.php is in the includes/templates/template_default/templates folder. Place the modified file in the includes/templates/MYTEMPLATE/templates folder.

An easy way for anyone to find the location of a particular file is to have a copy of the Zen Cart files and folders on their local computer. Then all they have to do is use the search feature (in My Computer or Explorer on a Windows system) to find out what folder a certain file is in.