Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Apr 2005
    Posts
    84
    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 :-)

  2. #2
    Join Date
    Nov 2005
    Posts
    77
    Plugin Contributions
    0

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

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

  3. #3
    Join Date
    Sep 2006
    Posts
    32
    Plugin Contributions
    0

    Default 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>

  4. #4
    Join Date
    Oct 2004
    Location
    Southport, UK
    Posts
    4,244
    Plugin Contributions
    20

    Default 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 !

  5. #5
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default 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!

  6. #6
    Join Date
    Nov 2004
    Posts
    68
    Plugin Contributions
    0

    Default 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?

  7. #7
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

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

    It looks like you litterally added "..." here:
    Code:
    $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.

  8. #8
    Join Date
    Mar 2007
    Location
    San Diego
    Posts
    6
    Plugin Contributions
    0

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

    Quote Originally Posted by gruntre69 View Post
    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 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:

    Code:
     if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone))

  9. #9
    Join Date
    Mar 2007
    Location
    San Diego
    Posts
    6
    Plugin Contributions
    0

    Default 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

    PHP Code:
    if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone)) { 

  10. #10
    Join Date
    Dec 2006
    Posts
    189
    Plugin Contributions
    0

    Default 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

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 How do I add the phone number to the contact us page? Thank you.
    By MagicMan in forum General Questions
    Replies: 3
    Last Post: 21 Jan 2016, 10:47 PM
  2. v150 Add Phone Number to Contact Us - phone number is not on the emails?
    By ljdream00 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 18 Apr 2012, 10:37 PM
  3. 1.3.8a how do I add phone number to contact form
    By cshart in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 28 Oct 2008, 06:30 AM
  4. How to add a Phone number to Contact us
    By monak83 in forum General Questions
    Replies: 1
    Last Post: 11 Jun 2008, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg