- Posts: 32
- Thank you received: 0
Contact us for more information Form Customisation
12 years 6 months ago - 12 years 6 months ago #150671
by drock
Contact us for more information Form Customisation was created by drock
-- HikaShop version -- : Essential: 2.3.0
-- Joomla version -- : 3.2
Hi,
I have customised Contact us for more information form to add extra fields by editing views>product>tmpl>contact.php
But the form sent to my email not sending the data submitted. Kindly help.
This is my updated source code:
Thanks
-- Joomla version -- : 3.2
Hi,
I have customised Contact us for more information form to add extra fields by editing views>product>tmpl>contact.php
But the form sent to my email not sending the data submitted. Kindly help.
This is my updated source code:
Code:
<?php
/**
* @package HikaShop for Joomla!
* @version 2.3.0
* @author hikashop.com
* @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><div id="hikashop_product_contact_<?php echo JRequest::getInt('cid');?>_page" class="hikashop_product_contact_page">
<fieldset>
<div class="" >
<h1><?php
if(!empty($this->product->images)) {
$image = reset($this->product->images);
$img = $this->imageHelper->getThumbnail($image->file_path, array(50,50), array('default' => true), true);
if($img->success) {
echo '<img src="'.$img->url.'" alt="" style="vertical-align:middle"/> ';
}
}
echo $this->product->product_name; ?></h1>
</div>
<?php
$formData = JRequest::getVar('formData','');
if(isset($this->element->name) && !isset($formData->name)){
$formData->name = $this->element->name;
}
if(isset($this->element->email) && !isset($formData->email)){
$formData->email = $this->element->email;
}
?>
<p>Please complete the details below and we will deal with your request upon receipt.</p>
<p>** - Indicates Required Field</p>
<form action="<?php echo hikashop_completeLink('product'); ?>" id="hikashop_contact_form" name="hikashop_contact_form" method="post">
<dl>
<dt><label for="data[contact][quantity]"><?php echo JText::_( 'HIKA_USER_QUANTITY' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_quantity" type="text" name="data[contact][quantity]" size="40" value="<?php echo $this->escape(@$formData->quantity);?>" />
</dd>
<dt><label for="data[contact][firstname]"><?php echo JText::_( 'HIKA_USER_FIRSTNAME' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_firstname" type="text" name="data[contact][firstname]" size="40" value="<?php echo $this->escape(@$formData->firstname);?>" />
</dd>
<dt><label for="data[contact][lastname]"><?php echo JText::_( 'HIKA_USER_LASTNAME' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_lastname" type="text" name="data[contact][lastname]" size="40" value="<?php echo $this->escape(@$formData->lastname);?>" />
</dd>
<dt><label for="data[contact][company]"><?php echo JText::_( 'HIKA_USER_COMPANY' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_company" type="text" name="data[contact][company]" size="40" value="<?php echo $this->escape(@$formData->company);?>" />
</dd>
<dt><label for="data[contact][country]"><?php echo JText::_( 'HIKA_USER_COUNTRY' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<select id="hikashop_contact_country" type="text" name="data[contact][country]" value="<?php echo $this->escape(@$formData->country);?>" >
<option value="">-- Select Country --</option>
<option value="USA">USA</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Other">Other</option>
</select>
</dd>
<dt><label for="data[contact][postcode]"><?php echo JText::_( 'HIKA_USER_POSTCODE' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_postcode" type="text" name="data[contact][postcode]" size="40" value="<?php echo $this->escape(@$formData->postcode);?>" />
</dd>
<dt><label for="data[contact][telephone]"><?php echo JText::_( 'HIKA_USER_TELEPHONE' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_telephone" type="text" name="data[contact][telephone]" size="40" value="<?php echo $this->escape(@$formData->telephone);?>" />
</dd>
<dt><label for="data[contact][name]"><?php echo JText::_( 'HIKA_USER_NAME' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_name" type="text" name="data[contact][name]" size="40" value="<?php echo $this->escape(@$formData->name);?>" />
</dd>
<dt><label for="data[contact][email]"><?php echo JText::_( 'HIKA_EMAIL' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_email" type="text" name="data[contact][email]" size="40" value="<?php echo $this->escape(@$formData->email);?>" />
</dd>
<dt><label for="data[contact][subject]"><?php echo JText::_( 'HIKA_USER_SUBJECT' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<input id="hikashop_contact_subject" type="text" name="data[contact][subject]" size="40" value="<?php echo $this->escape(@$formData->subject);?>" />
</dd>
<dt><label for="data[contact][altbody]"><?php echo JText::_( 'ADDITIONAL_INFORMATION' ); ?> : <span class="formRequired">*</span></label></dt>
<dd>
<textarea id="hikashop_contact_altbody" cols="30" rows="10" name="data[contact][altbody]" >
<?php if(isset($formData->altbody)) echo $formData->altbody; ?>
</textarea>
</dd>
</dl>
<input type="hidden" name="data[contact][product_id]" value="<?php echo JRequest::getInt('cid');?>" />
<input type="hidden" name="cid" value="<?php echo JRequest::getInt('cid');?>" />
<input type="hidden" name="option" value="<?php echo HIKASHOP_COMPONENT; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="ctrl" value="product" />
<input type="hidden" name="redirect_url" value="<?php $redirect_url = JRequest::getString('redirect_url', ''); echo $this->escape($redirect_url); ?>" />
<?php if(JRequest::getVar('tmpl', '') == 'component') { ?>
<input type="hidden" name="tmpl" value="component" />
<?php } ?>
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<div class="toolbar" id="toolbar" >
<div class="toolbar-left"> </div>
<div class="toolbar-right">
<button class="btn" type="button" onclick="checkFields();"><?php echo JText::_('HIKA_SUBMIT_ENQUIRY'); ?></button>
<?php if(JRequest::getCmd('tmpl', '') != 'component') { ?>
<button class="btn" type="button" onclick="history.back();"><?php echo JText::_('HIKA_CANCEL'); ?></button>
<?php } ?>
</div>
</div>
<div style="clear:both"></div>
</fieldset>
<p> </p>
<p>For a full list of chemicals available from Hawks Scientific, including pack sizes and pricing, <a href="#">click here.</a></p>
</div>
Thanks
Last edit: 12 years 6 months ago by drock.
Please Log in or Create an account to join the conversation.
12 years 6 months ago #150709
by nicolas
Replied by nicolas on topic Contact us for more information Form Customisation
Hi,
You need to edit the contact email via the menu System>Emails (Business edition only) or via the media/com_hikashop/mail (other editions) and add some code to display your fields value there.
For example:
<?php echo $data->element->company; ?>
You need to edit the contact email via the menu System>Emails (Business edition only) or via the media/com_hikashop/mail (other editions) and add some code to display your fields value there.
For example:
<?php echo $data->element->company; ?>
Please Log in or Create an account to join the conversation.
12 years 6 months ago #151032
by drock
Replied by drock on topic Contact us for more information Form Customisation
Hi,
I have added new fields PHP values. This is my "contact_request.preload.php"
seems not working as I am still not getting the data submitted. Also how to make the new field validate with required fields just like Name, Email and Additional Info fields.
Thanks
I have added new fields PHP values. This is my "contact_request.preload.php"
Code:
<?php
/**
* @package HikaShop for Joomla!
* @version 2.3.0
* @author hikashop.com
* @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
global $Itemid;
$url_itemid = '';
if(!empty($Itemid)) {
$url_itemid = '&Itemid=' . $Itemid;
}
$texts = array(
'MAIL_HEADER' => JText::_('HIKASHOP_MAIL_HEADER'),
'CONTACT_TITLE' => JText::_('CONTACT_EMAIL_TITLE'),
'CONTACT_BEGIN_MESSAGE' => JText::_('CONTACT_BEGIN_MESSAGE'),
'USER_MESSAGE' => JText::_('CONTACT_USER_MESSAGE'),
'USER' => JText::_('HIKA_USER'),
'PRODUCT' => JText::_('PRODUCT'),
'HI_USER' => JText::sprintf('HI_CUSTOMER', ''),
'FOR_PRODUCT' => JText::sprintf('CONTACT_REQUEST_FOR_PRODUCT', $data->product->product_name),
);
$admin_product_url = JRoute::_('administrator/index.php?option=com_hikashop&ctrl=product&task=edit&cid[]='.$data->product->product_id, false, true);
$front_product_url = hikashop_frontendLink('product&task=show&cid[]='.$data->product->product_id.$url_itemid);
$vars = array(
'LIVE_SITE' => HIKASHOP_LIVE,
'URL' => HIKASHOP_LIVE,
'USER_DETAILS' => htmlentities($data->element->name.' ( '.$data->element->email . ' )', ENT_COMPAT, 'UTF-8'),
'PRODUCT_DETAILS' => ('<a href="'.$admin_product_url.'">'.strip_tags($data->product->product_name.' ('.$data->product->product_code.')').'</a>'),
'FRONT_PRODUCT_DETAILS' => ('<a href="'.$front_product_url.'">'.strip_tags($data->product->product_name.' ('.$data->product->product_code.')').'</a>'),
'HIKA_USER_QUANTITY' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->quantity),
'HIKA_USER_FIRSTNAME' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->firstname),
'HIKA_USER_LASTNAME' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->lastname),
'HIKA_USER_COMPANY' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->company),
'HIKA_USER_COUNTRY' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->country),
'HIKA_USER_POSTCODE' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->postcode),
'HIKA_USER_TELEPHONE' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->telephone),
'HIKA_USER_SUBJECT' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->subject),
'USER_MESSAGE' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->altbody),
);
seems not working as I am still not getting the data submitted. Also how to make the new field validate with required fields just like Name, Email and Additional Info fields.
Thanks
Please Log in or Create an account to join the conversation.
12 years 6 months ago #151052
by nicolas
Replied by nicolas on topic Contact us for more information Form Customisation
Hi,
You should not add that code in the preload but in the main file of the email.
If you want to add more checks on the fields, you need to add your javascript checks in the onclick attribute of the submit button of the contact.php view file:
You should not add that code in the preload but in the main file of the email.
If you want to add more checks on the fields, you need to add your javascript checks in the onclick attribute of the submit button of the contact.php view file:
Code:
<button class="btn" type="button" onclick="checkFields();"><?php echo JText::_('HIKA_SUBMIT_ENQUIRY'); ?></button>
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151191
by drock
Replied by drock on topic Contact us for more information Form Customisation
Hi,
I am a bit confused. Can you tell me which file to edit to add additional fields to work please? I have already added the fields into contact.php. But when submitting the data is not being sent through email.
For the required field, which JS file to edit to make the new fields added validate as Required and turn red if they are blank.
Thanks
I am a bit confused. Can you tell me which file to edit to add additional fields to work please? I have already added the fields into contact.php. But when submitting the data is not being sent through email.
For the required field, which JS file to edit to make the new fields added validate as Required and turn red if they are blank.
Thanks
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151210
by Xavier
Replied by Xavier on topic Contact us for more information Form Customisation
Hi,
The file to edit is "contact_request.html.php" in the "media\com_hikashop\mail" folder.
You can make the changes directly in the view "product / contact".
The file to edit is "contact_request.html.php" in the "media\com_hikashop\mail" folder.
You can make the changes directly in the view "product / contact".
Please Log in or Create an account to join the conversation.
12 years 5 months ago - 12 years 5 months ago #151340
by drock
Replied by drock on topic Contact us for more information Form Customisation
Hi,
Thanks for your reply.
Into the contact_request.html.php there is values like:
{VAR:USER_DETAILS}, {VAR:PRODUCT_DETAILS}, {VAR:USER_MESSAGE}
How can I add my new fields here? Do I need to mention their Values somewhere like {VAR:USER_QUANTITY} if so, then where should I mention those values?
Best
Thanks for your reply.
Into the contact_request.html.php there is values like:
{VAR:USER_DETAILS}, {VAR:PRODUCT_DETAILS}, {VAR:USER_MESSAGE}
How can I add my new fields here? Do I need to mention their Values somewhere like {VAR:USER_QUANTITY} if so, then where should I mention those values?
Best
Last edit: 12 years 5 months ago by drock.
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151345
by drock
Replied by drock on topic Contact us for more information Form Customisation
Hi,
I have solved the email issue:
Added new fields value as {VAR:USER_QUANTITY}, {VAR:USER_COUNTRY}, etc. into main>contact_request_html.php
then defined values into contact_request_preload.php and finally add those extra fields into language>en-GB.com_hikashop.ini
Still struggling for the validation of the new fields into products>contact.php file
Any help would be appreciated.
Thanks
I have solved the email issue:
Added new fields value as {VAR:USER_QUANTITY}, {VAR:USER_COUNTRY}, etc. into main>contact_request_html.php
then defined values into contact_request_preload.php and finally add those extra fields into language>en-GB.com_hikashop.ini
Still struggling for the validation of the new fields into products>contact.php file
Any help would be appreciated.
Thanks
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 5 months ago #151359
by Mohamed Thelji
Replied by Mohamed Thelji on topic Contact us for more information Form Customisation
Hello,
For new fields you'll probably be able to display them by using some PHP code like :
For new fields you'll probably be able to display them by using some PHP code like :
Code:
<?php
echo $_POST["YOURNEWFIELD"];
?>
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151497
by drock
Replied by drock on topic Contact us for more information Form Customisation
Hi,
It worked
also validation worked by editing view.html.php
Thanks for your help.
It worked
Thanks for your help.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 5
- Thank you received: 0
11 years 5 months ago #199044
by feliperozo13
Replied by feliperozo13 on topic Contact us for more information Form Customisation
Hi! I have the same problem with form validation. In contact_request.preload.php what I have to insert?
Thanks
Thanks
Please Log in or Create an account to join the conversation.
11 years 5 months ago #199113
by nicolas
Replied by nicolas on topic Contact us for more information Form Customisation
Hi,
HikaShop can now handle fields on the contact form without any code modification. Just go in the menu Display>Custom fields and create the fields you want with the table "contact" selected.
HikaShop can now handle fields on the contact form without any code modification. Just go in the menu Display>Custom fields and create the fields you want with the table "contact" selected.
Please Log in or Create an account to join the conversation.
Time to create page: 0.252 seconds