Forums / General Questions / I want to add required fields to Contact Us

I want to add required fields to Contact Us

Locked

Views: 2,166

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
16 Apr 2010, 10:31 PM
#1
jaybird avatar

jaybird

New Zenner

Join Date:
Nov 2009
Posts:
33
Plugin Contributions:
0

I want to add required fields to Contact Us

Hope this is the right thread; if not, please redirect me to the correct one.
I want to add a couple required fields (not to the create account form), but to the Contact Us form generated from the Call For Price button. I think it might be generated from the same code as the Create Account form, and if so, I'll try the instructions per xlr82quik and CraigW here: http://www.zen-cart.com/forum/showthread.php?t=73181 . Anyone know if this is the way to go?
Using ZenCart 1.3.8a

TIA,
Jay

17 Apr 2010, 8:45 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: I want to add required fields to Contact Us

I think the file you need to make a copy of for your template is located in the /includes/templates/template_default/templates/tpl_contact_us_default.php

This is a core file and should not be edited - make a copy and place it in your template structure

Zen-Venom Get Bitten

17 Apr 2010, 5:46 PM
#3
jaybird avatar

jaybird

New Zenner

Join Date:
Nov 2009
Posts:
33
Plugin Contributions:
0

Re: I want to add required fields to Contact Us

kobra:

I think the file you need to make a copy of for your template is located in the /includes/templates/template_default/templates/tpl_contact_us_default.php

This is a core file and should not be edited - make a copy and place it in your template structure

Thank you, kobra, for the quick response. I WAS able to add another field by inserting an extra copy of Lines 135,137,139

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>

<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" />

and saving the file to the /includes/templates/mystore/templates folder. I tried changing some of the labels on these lines, but the resulting extra field title remained “Email Address:” There must be more necessary changes, but I only know enough php to be dangerous. . .

Could you illustrate the necessary changes in the new 3 lines, and / or point me to other files that might also need to be changed?

Thank you.

17 Apr 2010, 8:03 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: I want to add required fields to Contact Us

I want to add a couple required fields

There must be more necessary changes, but I only know enough php to be dangerous. . .
You posted the lines you copied but not what you changed them to
Also you have not explained what you are attempting to do???
If only to receive these new fields in the contact email that is one thing but if you want this info stored in the DB somewhere then that is additional coding
If I assume that you only want it emailed then this is standard html form assembly
Try http://www.w3schools.com/

Zen-Venom Get Bitten

17 Apr 2010, 10:53 PM
#5
jaybird avatar

jaybird

New Zenner

Join Date:
Nov 2009
Posts:
33
Plugin Contributions:
0

Re: I want to add required fields to Contact Us

Sorry; I'll try to clarify. I'm not trying to include or retain any extra info in the database. All I want is to have a couple extra fields of information for the customer to fill in and be sent via e-mail.

I sucessfuly added an extra field by copying the 3 lines for 'contactname' and made these changes:

<label class="inputLabel" for="**topampbrand**"><?php echo **Top_Brand**; ?></label>

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

After upload, this resulted in an extra field titled: "Top_Brand".

Upon filling in all 3 fields and clicking Send, e-mail is received with the Full Name field info, the Email Address field info, but NOTHING indicating the (new) Top_Brand field info. This variable must require some code addition somewhere, in order to be included in the e-mail submission, but I haven't been able to find where.

Hope this helps explain, and thank you for any suggestions.
Jay

18 Apr 2010, 1:16 AM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: I want to add required fields to Contact Us

You have copied this and the cap text in red is the variable

<label class="inputLabel" for="contactname"><?php echo ENTRY_NAME; ?></label>
<?php echo zen_draw_input_field('contactname', $name, ' size="40" id="contactname"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

Use the developers toolkit to find other files where that variable is used and how - - replicate for your variable
https://www.zen-cart.com/tutorials/index.php?article=38
https://www.zen-cart.com/tutorials/index.php?article=39

Some:
modules/pages/contact_us/header_php.php
languages/english/contact_us.php
email/email_template_contact_us.html

Zen-Venom Get Bitten

18 Apr 2010, 1:26 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: I want to add required fields to Contact Us

While I've not used them, there are two addons that add certain fields to Contact Us. Perhaps you might find inspiration with them. At least use WinMerge to compare your files against the ones in their contributions to see what they changed, and that should give you some clues to what/how you can change things for your own unique needs:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=331
http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=337

Or there's this much longer discussion on a different, but similar, topic from awhile back: http://www.zen-cart.com/forum/showthread.php?t=4855 . The code shared in many posts in that discussion is from older versions of Zen Cart, but the concepts remain. Again, something for inspiration, although not suitable for a direct copy-and-paste.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Apr 2010, 10:32 PM
#8
jaybird avatar

jaybird

New Zenner

Join Date:
Nov 2009
Posts:
33
Plugin Contributions:
0

Re: I want to add required fields to Contact Us

GOT IT. THANK YOU kobra & DrByte. Couldn't have got it without your excellent help.

Not sure if this helps anyone for the regular Contact Us page, but for anyone else wanting to add extra Fields to the "Call For Price" Contact Us page, these are the steps I used:

1: includes/templates/YOURS/templates/tpl_contact_us_default.php
add lines for the new Field you want.
This is the creation of any new Field, with the variable
$....
This variable is crucial for Step 3.

2: /includes/languages/english/YOURS/contact_us.php
change the name you want displayed for the Field.
This file displays the name of the Field the way you want
it to show on the web page.

3: /includes/modules/pages/contact_us/header_php.php
Thru the entire file, add lines as needed for the variable $.... that you created in Step 1 (tpl_contact_us_default.php), and add instances as needed for the variable $. . . you created. This will send the customer-supplied information from the Field to you via e-mail. (I was unable to place this in any override folder).

Lines for insertion are approximately 17, 23, 52, 55, 68.

If you know of a way to place the header_php.php file in an override folder, please let me know; I tried several places, but without success.

Thank you again,
Jay

19 Apr 2010, 3:47 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: I want to add required fields to Contact Us

There is intentionally no override for header_php.php files.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Apr 2010, 5:04 AM
#10
jaybird avatar

jaybird

New Zenner

Join Date:
Nov 2009
Posts:
33
Plugin Contributions:
0

Re: I want to add required fields to Contact Us

I'll make a note to manually apply these changes to the header_php.php file when upgrading to a new version.

And FWIW, I noticed that when I made these changes to the Contact Us page (called from the 'Call for Price' product page button), this also results in identical changes to the Contact Us page that's brought up when you click the Contact Us button from the Information sidebox. In other words, the 2 Contact Us pages are not independent of each other; they are identical, so changes made to one result in parallel changes to the other.

19 Apr 2010, 5:10 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: I want to add required fields to Contact Us

Correct. All "Contact Us" links point to the one-and-only contact_us page in your site.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.