This is how I added a " Ask a Question " tab to the product page. It uses jquery validation and ajax submission/response. Very easy to implement. The form will email you the question along with the product code so you know what they are asking a question about.
Demo here: http://labeldomain.com/50-LDTR-2313
P.S. THE DEMO IS LIVE ! PLEASE DO NOT EXCESSIVELY TEST THE FORM AS I WILL GET ALL EMAILS

Original Files here: http://www.tutwow.com/htmlcss/create-a- ... y-and-php/
Repackaged/Modified for Opencart here: http://labeldomain.com/contact_form.zip
I modified the CSS by removing some styles that conflicted with OC.
I added hidden product id field so we know what they are asking a question about

I removed table styling and formatted like default template.
There are some paid versions that do this, but with a few minutes of your time you can have your own and customize to your needs.
Download Repackaged/Modified contact_form.zip and extract
Upload folder contact_form to ........... Yoursite.com/contact_form
Add contents of add_to_header.txt to catalog/view/theme/yourtheme/template/common/header.tpl
Code: Select all
<script type="text/javascript" src="contact_form/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="contact_form/js/jquery.form.js"></script>
<script type="text/javascript" src="contact_form/js/contact.js"></script>
<link rel="stylesheet" href="contact_form/style.css" type="text/css" />
Find:
Code: Select all
<a href="#tab-related"><?php echo $tab_related; ?> (<?php echo count($products); ?>)</a>
<?php } ?>
Code: Select all
<a href="#tab-related"><?php echo $tab_related; ?> (<?php echo count($products); ?>)</a>
<?php } ?>
<?php // Product Question tab code starts here ?>
<a href="#tab-contact">Ask a Question</a>
</div>
<div id="tab-contact" class="tab-content">
<div id="response">
<div id="wrap">
<h3>Ask a question about: <?php echo $model; ?></h3>
<form id="contactform" action="contact_form/processForm.php" method="post">
<input type="hidden" id="product" name="product" value="<?php echo $model; ?>" /></br></br>
<b><label for="name">Name:</label></b></br>
<input type="text" id="name" name="name" /></br></br>
<b><label for="email">Email:</label></b></br>
<input type="text" id="email" name="email" /></br></br>
<b><label for="message">Message:</label></b></br>
<textarea id="message" name="message" rows="5" cols="40" ></textarea></br></br>
<input type="submit" value="Submit" id="send" class="button"/>
</form>
</div>
</div>
Code: Select all
// Send the email
$to = "YOUR-EMAIL@YOUR-DOMAIN.COM"; // Your email goes here.... example: admin@yourdomain.com
$subject = "Question about: $product";
$message = "$message";
$headers = "From: $email";
1. download contact_form.zip and extract
2. Upload contact_form folder to root of your site Ex: Yoursite.com/contact_form
3. Add contents of add_to_header.txt to header.tpl file
4. Add contents of add_to_product-tpl.txt to product.tpl
5. Edit processForm.php and add your email address around line 50
I have only tested this with the default theme and have no idea how it works with ANY other theme so please dont ask, you will need to test this on your own. I tested on my localhost test site before going live, I suggest you do too.
P.S. THE DEMO IS LIVE ! PLEASE DO NOT EXCESSIVELY TEST THE FORM AS I WILL GET ALL EMAILS
