I've created a new template file with a navigation menu and a contact form, which slides out with jquery when a link on the navigation is clicked, editing the form depending on which link is clicked.
This .phtml template file is loaded in the product view page, just below the add to cart form. It's basically an enquiry form for each product for a customer to send questions for this product.
As I need to display extra input fields (Product name, id & current url for example), I need to edit the e-mail template to support those extra vars.
1) Is there a way to define which Transaction E-mail Template is used for a specific form, or is this only possible with a custom module rather than a custom template phtml file?
The second issue is that I do not want to direct the customer to the contact page after submitting, but rather reload the product page with a notice that the message has been sent.
2) Is there a way to reload the product page with the notice msg after submitting the form, rather than being redirected to the contacts page?
---- EDIT1 ----
I've managed to do 2) by using the prototype ajax.update to submit via ajax - however it still needs to output the response from the contact form (the whole contact page with success message), which I just hide in a div with the id #noDisplay
My JS Script:
<script type="text/javascript">
//<![CDATA[
var formId = 'customContactForm';
var myForm = new VarienForm(formId, true);
var postUrl = '<?php echo $this->getUrl("contacts/index/post") ?>';
function doAjax() {
if (myForm.validator.validate()) {
new Ajax.Updater(
{ success:'noDisplay' },
postUrl, {
method:'post',
asynchronous:true,
evalScripts:false,
onComplete:function(request, json) {
Element.hide('custom-contact');
Element.show('formSuccess');
Form.reset(formId);
},
onLoading:function(request, json){
Element.show('formLoader');
},
parameters: $(formId).serialize(true),
}
);
}
};
function FadeEffect(element, effectduration, effectdelay){
new Effect.Fade(element, { duration:effectduration, delay:effectdelay });
}
new Event.observe(formId, 'submit', function(e){
e.stop();
doAjax();
FadeEffect('formSuccess', 2, 4);
});
//]]>
</script>
Thanks in advance.