Hi,
All email services is working, like order, customer registration, and etc.
But when it comes to Product Contact Us, the form won't send email.
Here is the code for the contact.php:
<div id="hikashop_product_contact_<?php echo JRequest::getInt('cid');?>_page" class="hikashop_product_contact_page">
<fieldset>
<div class="" style="float:left">
<h1><?php
if(!empty($this->product)) {
$doc = JFactory::getDocument();
$doc->setMetaData( 'robots', 'noindex' );
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;
} else {
echo @$this->title;
}
?></h1>
</div>
<div class="toolbar" id="toolbar" style="float: right;">
<button class="btn" type="button" onclick="checkFields();"><img src="<?php echo HIKASHOP_IMAGES; ?>ok.png" alt=""/><?php echo JText::_('OK'); ?></button>
<?php if(JRequest::getCmd('tmpl', '') != 'component') { ?>
<button class="btn" type="button" onclick="history.back();"><img src="<?php echo HIKASHOP_IMAGES; ?>cancel.png" alt=""/><?php echo JText::_('HIKA_CANCEL'); ?></button>
<?php } ?>
</div>
<div style="clear:both"></div>
</fieldset>
<?php
$formData = JRequest::getVar('formData','');
if(empty($formData))
$formData = new stdClass();
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;
}
?>
<form action="<?php echo hikashop_completeLink('product'); ?>" id="hikashop_contact_form" name="hikashop_contact_form" method="post">
<dl>
<dt id="hikashop_contact_name_name" class="hikashop_contact_item_name">
<label for="data[contact][name]"><?php echo JText::_( 'HIKA_USER_NAME' ); ?></label>
</dt>
<dd id="hikashop_contact_value_name" class="hikashop_contact_item_value">
<input id="hikashop_contact_name" type="text" name="data[contact][name]" size="40" value="<?php echo $this->escape(@$formData->name);?>" />
</dd>
<dt id="hikashop_contact_name_email" class="hikashop_contact_item_name">
<label for="data[contact][email]"><?php echo JText::_( 'HIKA_EMAIL' ); ?></label>
</dt>
<dd id="hikashop_contact_value_email" class="hikashop_contact_item_value">
<input id="hikashop_contact_email" type="text" name="data[contact][email]" size="40" value="<?php echo $this->escape(@$formData->email);?>" />
</dd>
<?php
if(!empty($this->contactFields)){
foreach ($this->contactFields as $fieldName => $oneExtraField) {
$itemData = @$formData->$fieldName;
?>
<div id="hikashop_contact_<?php echo $oneExtraField->field_namekey; ?>">
<dt id="hikashop_contact_item_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_contact_item_name">
<label for="data[contact][<?php echo $oneExtraField->field_namekey; ?>]">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</label>
</dt>
<dd id="hikashop_contact_item_value_<?php echo $oneExtraField->field_id;?>" class="hikasho_contact_item_value"><?php
$onWhat='onchange';
if($oneExtraField->field_type=='radio')
$onWhat='onclick';
$oneExtraField->product_id = JRequest::getInt('cid');
echo $this->fieldsClass->display($oneExtraField,$itemData,'data[contact]['.$oneExtraField->field_namekey.']',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'contact\',0);"');
?>
</dd>
</div>
<?php
}
}
if(!empty($this->extra_data['fields'])) {
foreach($this->extra_data['fields'] as $key => $value) {
?> <dt id="hikashop_contact_<?php echo $key; ?>_email" class="hikashop_contact_item_name">
<label><?php echo JText::_($value['label']); ?></label>
</dt>
<dd id="hikashop_contact_<?php echo $key; ?>_email" class="hikashop_contact_item_value">
<?php echo $value['content']; ?>
</dd>
<?php
}
}
?>
<dt id="hikashop_contact_name_altbody" class="hikashop_contact_item_name">
<label for="data[contact][altbody]"><?php echo JText::_( 'ADDITIONAL_INFORMATION' ); ?></label>
</dt>
<dd id="hikashop_contact_value_altbody" class="hikashop_contact_item_value">
<textarea id="hikashop_contact_altbody" cols="60" rows="10" name="data[contact][altbody]" style="width:100%;"><?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(!empty($this->extra_data['hidden'])) {
foreach($this->extra_data['hidden'] as $key => $value) {
echo "\t\t" . '<input type="hidden" name="'.$this->escape($key).'" value="'.$this->escape($value).'" />' . "\r\n";
}
}
if(JRequest::getVar('tmpl', '') == 'component') {
?> <input type="hidden" name="tmpl" value="component" />
<?php
}
echo JHTML::_( 'form.token' );
?>
</form>
</div>
The code for contact_request.html.php:
<style type="text/css">
body.hikashop_mail { background-color:#ffffff; color:#575757; }
.ReadMsgBody{width:100%;}
.ExternalClass{width:100%;}
div, p, a, li, td {-webkit-text-size-adjust:none;}
@media (min-width:600px){
#hikashop_mail {width:600px !important;margin:auto !important;}
.pict img {max-width:500px !important;height:auto !important;}
}
@media (max-width:330px){
#hikashop_mail{width:300px !important; margin:auto !important;}
table[class=w600], td[class=w600], table[class=w598], td[class=w598], table[class=w500], td[class=w500], img[class="w600"]{width:100% !important;}
td[class="w49"] { width: 10px !important;}
.pict img {max-width:278px; height:auto !important;}
}
@media (min-width:331px) and (max-width:480px){
#hikashop_mail{width:450px !important; margin:auto !important;}
table[class=w600], td[class=w600], table[class=w598], td[class=w598], table[class=w500], td[class=w500], img[class="w600"]{width:100% !important;}
td[class="w49"] { width: 20px !important;}
.pict img {max-width:408px; height:auto !important;}
}
h1{color:#1c8faf;font-size:16px;font-weight:bold;border-bottom:1px solid #ddd; padding-bottom:10px;}
h2{color:#89a9c1;font-size:14px;font-weight:bold;margin-top:20px;margin-bottom:5px;border-bottom:1px solid #d6d6d6;padding-bottom:4px;}
a:visited{cursor:pointer;color:#2d9cbb;text-decoration:none;border:none;}
</style>
<div id="hikashop_mail" style="font-family:Arial, Helvetica,sans-serif;font-size:12px;line-height:18px;width:100%;background-color:#ffffff;padding-bottom:20px;color:#5b5b5b;">
<table class="w600" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:18px;margin:auto;background-color:#ebebeb;" border="0" cellspacing="0" cellpadding="0" width="600" align="center">
<tr style="line-height: 0px;">
<td class="w600" style="line-height:0px" width="600" valign="bottom">
<img class="w600" src="{VAR:LIVE_SITE}/media/com_hikashop/images/mail/header_black.png" border="0" alt="" />
</td>
</tr>
<tr>
<td class="w600" style="" width="600" align="center">
<table class="w600" border="0" cellspacing="0" cellpadding="0" width="600" style="margin:0px;font-family: Arial, Helvetica, sans-serif;font-size:12px;line-height:18px;">
<tr>
<td class="w20" width="20"></td>
<td class="w560 pict" style="text-align:left; color:#575757" width="560">
<div id="title" style="font-family: Arial, Helvetica, sans-serif;font-size:12px;line-height:18px;">
<img src="{VAR:LIVE_SITE}/media/com_hikashop/images/icons/icon-48-forum.png" border="0" alt="" style="float:left;margin-right:4px;"/>
<h1 style="color:#1c8faf !important;font-size:16px;font-weight:bold; border-bottom:1px solid #ddd; padding-bottom:10px">
{TXT:CONTACT_TITLE}
</h1>
<!--{IF:PRODUCT}-->
<h2 style="color:#1c8faf !important;font-size:12px;font-weight:bold; padding-bottom:10px">
{TXT:FOR_PRODUCT}
</h2>
<!--{ENDIF:PRODUCT}-->
</div>
</td>
<td class="w20" width="20"></td>
</tr>
<tr>
<td class="w20" width="20"></td>
<td style="border:1px solid #adadad;background-color:#ffffff;">
<div class="w550" width="550" id="content" style="font-family: Arial, Helvetica, sans-serif;font-size:12px;line-height:18px;margin-left:5px;margin-right:5px;">
<p>
<h3 style="color:#393939 !important; font-size:14px; font-weight:normal; font-weight:bold;margin-bottom:0px;padding:0px;">{TXT:HI_USER}</h3>
{TXT:CONTACT_BEGIN_MESSAGE}
</p>
<table class="w550" border="0" cellspacing="0" cellpadding="0" width="550" style="margin-top:10px;font-family: Arial, Helvetica, sans-serif;font-size:12px;line-height:18px;">
<tr>
<td style="color:#1c8faf !important;font-size:12px;font-weight:bold;">{TXT:USER}</td>
<td>{VAR:USER_DETAILS}</td>
</tr>
<tr>
<td style="color:#1c8faf !important;font-size:12px;font-weight:bold;">{TXT:PRODUCT}</td>
<td>{VAR:PRODUCT_DETAILS}</td>
</tr>
</table>
<h1 style="color:#1c8faf !important;font-size:16px;font-weight:bold;border-top:1px solid #ddd;border-bottom:1px solid #ddd;padding-top:10px;padding-bottom:10px;">
{TXT:USER_MESSAGE}
</h1>
<p>
{VAR:USER_MESSAGE}
</p>
</div>
</td>
<td class="w20" width="20"></td>
</tr>
</table>
</td>
</tr>
<tr style="line-height: 0px;">
<td class="w600" style="line-height:0px" width="600" valign="top">
<img class="w600" src="{VAR:LIVE_SITE}/media/com_hikashop/images/mail/footer_black.png" border="0" alt="--" />
</td>
</tr>
</table>
</div>
And contact_request.preload.php:
<?php [attachment=34920]Contact Us Form.PNG[/attachment]
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' => '',
);
if(!empty($data->product)) {
$texts['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);
$productClass = hikashop_get('class.product');
$productClass->addAlias($data->product);
$front_product_url = hikashop_frontendLink('index.php?option=com_hikashop&ctrl=product&task=show&cid='.$data->product->product_id.'&name='.$data->product->alias.$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' => '',
'FRONT_PRODUCT_DETAILS' => '',
'PRODUCT' => !empty($data->product),
'USER_MESSAGE' => str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->altbody),
);
if(!empty($data->product)) {
$vars['PRODUCT_DETAILS'] = '<a href="'.$admin_product_url.'">'.strip_tags($data->product->product_name.' ('.$data->product->product_code.')').'</a>';
$vars['FRONT_PRODUCT_DETAILS'] = '<a href="'.$front_product_url.'">'.strip_tags($data->product->product_name.' ('.$data->product->product_code.')').'</a>';
}
if(hikashop_level(1)) {
$null = null;
$fieldsClass = hikashop_get('class.field');
$contactFields = $fieldsClass->getFields('frontcomp',$null,'contact');
if(!empty($contactFields)){
foreach($contactFields as $field){
$namekey = $field->field_namekey;
if(empty($data->element->$namekey) && !strlen($data->element->$namekey)) continue;
$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$data->element->$namekey,'user_email').'</p>';
}
}
}
Please help.
And thanks in advance.