Product Contact Us Not Sending Email

  • Posts: 2
  • Thank you received: 0
7 years 11 months ago #256579

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.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #256595

Hi,

I'm not sure what you're giving us copies of these files ?
If you've modified them and you're thinking that it might come from the modifications, then try with an original copy of the file and you'll quickly see if it comes from your modifications.

First, check that you see the email under the menu Customers>Emails history of your backend.
If you do, then it means that HikaShop sent the email to your email server so that your email server could send the email to the receiver.
If the email didn't arrive, you would have to look at the error log of the email server to understand why the email server didn't send it. And in that case, you'll likely need to contact your hosting company with the information from the email in the menu Customers>Emails history so that they can easily find it in their records.

Please Log in or Create an account to join the conversation.

  • Posts: 2
  • Thank you received: 0
7 years 11 months ago #256675

Sorry that I put up all that codes because I'am a not a PHP developer, so I posted all the codes assuming that you guys might spot the problem. And I don't have a original copy of the files, after I edited the files.
And now I don't know if I messed up the codes.

Already checked the customer email history.
And don't see any email records regarding the product contact email.

Last edit: 7 years 11 months ago by ronneljames.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #256706

Hi,

You can download the original install package of HikaShop via the menu My account>My subscriptions on our website.
You'll find the original files in the zip.
The mail files will be in media/mail/ and the contact.php view file will be in front/views/product/

If you don't see any contact email stored in the Customers>Emails history and you don't get any error message when you submit a contact request, then the problem is with the way one of these files is customized.

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum