Post by smokelight » Sat Jan 07, 2012 2:32 pm

hello i have this vqmod for ask a Qestion work good but i need help how i can edit this so it will show on the email the product id / name please help See the full script :

<modification>
<id>Ask a Qestion</id>
<version>2</version>
<vqmver>1.0.8</vqmver>

<file name="catalog/language/english/product/product.php">
<operation>
<search position="after">
<![CDATA[
$_['text_error'] = 'Product not found!';
]]></search>
<add>
<![CDATA[
$_['text_message'] = '<p>Your enquiry has been successfully sent to the store owner!</p>';
$_['entry_email'] = 'E-Mail Address:';
$_['entry_enquiry'] = 'Enquiry:';
$_['email_subject'] = 'Enquiry %s';
$_['tab_extra'] = 'Ask a Question';
$_['error_email'] = 'E-Mail Address does not appear to be valid!';
$_['error_enquiry'] = 'Enquiry must be between 10 and 3000 characters!';
]]></add>
</operation>
</file>


<file name="catalog/controller/product/product.php">
<operation>
<search position="before">
<![CDATA[
$this->data['tags'] = array();
]]></search>
<add>
<![CDATA[
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
$mail->send();

$this->redirect($this->url->link('information/contact/success'));
}

$this->data['text_location'] = $this->language->get('text_location');
$this->data['text_contact'] = $this->language->get('text_contact');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['text_telephone'] = $this->language->get('text_telephone');
$this->data['text_fax'] = $this->language->get('text_fax');
$this->data['tab_extra'] = $this->language->get('tab_extra');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');

if (isset($this->error['name'])) {
$this->data['error_name'] = $this->error['name'];
} else {
$this->data['error_name'] = '';
}

if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}

if (isset($this->error['enquiry'])) {
$this->data['error_enquiry'] = $this->error['enquiry'];
} else {
$this->data['error_enquiry'] = '';
}

if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}

$this->data['button_continue'] = $this->language->get('button_continue');

$this->data['action'] = $this->url->link('information/contact');
$this->data['store'] = $this->config->get('config_name');
$this->data['address'] = nl2br($this->config->get('config_address'));
$this->data['telephone'] = $this->config->get('config_telephone');
$this->data['fax'] = $this->config->get('config_fax');

if (isset($this->request->post['name'])) {
$this->data['name'] = $this->request->post['name'];
} else {
$this->data['name'] = $this->customer->getFirstName();
}

if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} else {
$this->data['email'] = $this->customer->getEmail();
}

if (isset($this->request->post['enquiry'])) {
$this->data['enquiry'] = $this->request->post['enquiry'];
} else {
$this->data['enquiry'] = '';
}

if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->data['captcha'] = '';
}

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/contact.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/contact.tpl';
} else {
$this->template = 'default/template/information/contact.tpl';
}

$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);

$this->response->setOutput($this->render());
]]></add>
</operation>

<operation>
<search position="before">
<![CDATA[
public function review() {
]]></search>
<add>
<![CDATA[
public function success() {
$this->language->load('product/product');

$this->document->setTitle($this->language->get('heading_title'));

$this->data['breadcrumbs'] = array();

$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);

$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('product/product'),
'separator' => $this->language->get('text_separator')
);

$this->data['heading_title'] = $this->language->get('heading_title');

$this->data['text_message'] = $this->language->get('text_message');

$this->data['button_continue'] = $this->language->get('button_continue');

$this->data['continue'] = $this->url->link('common/home');

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/success.tpl';
} else {
$this->template = 'default/template/common/success.tpl';
}

$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);

$this->response->setOutput($this->render());
}

private function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}

if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}

if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}

if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$this->error['captcha'] = $this->language->get('error_captcha');
}

if (!$this->error) {
return true;
} else {
return false;
}
}
]]></add>
</operation>
</file>


<file name="catalog/view/theme/default/template/product/product.tpl">
<operation>
<search position="after" offset="1">
<![CDATA[
<a href="#tab-related"><?php echo $tab_related; ?> (<?php echo count($products); ?>)</a>
]]></search>
<add>
<![CDATA[
<a href="#tab-extra"><?php echo $tab_extra; ?></a>
]]></add>
</operation>
<operation>
<search position="before">
<![CDATA[
<?php if ($tags) { ?>
]]></search>
<add>
<![CDATA[
<div id="tab-extra" class="tab-extra">
<table class="attribute">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="contact">
<div class="contact-info">
</div>
<div class="content">
<b><?php echo $entry_name; ?></b><br />
<input type="text" name="name" value="<?php echo $name; ?>" />
<br />
<?php if ($error_name) { ?>
<span class="error"><?php echo $error_name; ?></span>
<?php } ?>
<br />
<b><?php echo $entry_email; ?></b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?>
<br />
<b><?php echo $entry_enquiry; ?></b><br />
<textarea name="enquiry" cols="40" rows="10" style="width: 99%;"><?php echo $enquiry; ?></textarea>
<br />
<?php if ($error_enquiry) { ?>
<span class="error"><?php echo $error_enquiry; ?></span>
<?php } ?>
<br />
<b><?php echo $entry_captcha; ?></b><br />
<input type="text" name="captcha" value="<?php echo $captcha; ?>" />
<br />
<img src="index.php?route=information/contact/captcha" alt="" />
<?php if ($error_captcha) { ?>
<span class="error"><?php echo $error_captcha; ?></span>
<?php } ?>
</div>
<div class="buttons">
<div class="right"><a onclick="$('#contact').submit();" class="button"><span><?php echo $button_continue; ?></span></a></div>
</div>
</form>
</table>
</div>
]]></add>
</operation>
</file>

</modification>

New member

Posts

Joined
Wed Nov 23, 2011 1:59 am

Post by smokelight » Sun Jan 08, 2012 4:32 am

Please help

New member

Posts

Joined
Wed Nov 23, 2011 1:59 am

Post by tsd » Mon Aug 20, 2012 7:28 am

Hi all,
Sorry for my english.

I have the same problem.
I've tried changing this:

Code: Select all

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
For this:

Code: Select all

$mail->setText('Enquiry about: <a href="'.$this->url->link('product/product', 'product_id=' . $product_id).'">'.$product_info['name'].'</a>: <hr /> '.strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
The same change works well for:

Code: Select all

<div id="tab-extra" class="tab-extra"><p><?php echo $text_intro; ?><a href="<?php echo $link_product; ?>"><?php echo $product_info['name']; ?></a></p>
But I found that the script sends the email as if sent from the contact form.

Someone could help? Thanks.

tsd
Newbie

Posts

Joined
Sat Aug 18, 2012 6:32 pm

Post by tsd » Mon Aug 20, 2012 10:12 pm

Hi all,
I worked the last day to improve this very useful extension.
Thank to the creator for having planted the seed of something that can offer so many possibilities.

If you want to download my version (with the possibility of sending in the body of the email, the name, link and resizable image of the product), here is the link:

http://www.opencart.com/index.php?route ... on_id=7868

TIPS:

The secret was in the line:

Code: Select all

$this->data['action'] = $this->url->link('information/contact');
This line send all the form data to the contact module. First I've changed this line for:

Code: Select all

$this->data['action'] = $this->url->link('product/product');


And with some minor changes... here is my extension!

I hope you enjoy it!

Bye.

tsd
Newbie

Posts

Joined
Sat Aug 18, 2012 6:32 pm
Who is online

Users browsing this forum: No registered users and 47 guests