Post by allenshea » Sun Jan 01, 2012 5:25 pm

How can I add Product name to $mail->setSubject, when sending out mails from Product page?

Code: Select all

    	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'));
    	}
The mod can find http://www.opencart.com/index.php?route ... on_id=4472

If anyone know how to modify it. Please let me know. Thanks!

I know nothing about PHP and SQL, but I still try my best to understand it.


Active Member

Posts

Joined
Mon Dec 14, 2009 10:01 pm

Post by designbuyers » Wed Feb 01, 2012 2:08 am

This dose not include the product name when sending email.

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by straightlight » Wed Feb 01, 2012 2:32 am

In AskQuestion.xml file,

find:

Code: Select all

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
replace with:

Code: Select all

$mail->setSubject(html_entity_decode(str_replace(array("{posted_name}", "{product_name}", "{posted_date}"), array($this->request->post['name'], $product_info['name'], date('Y-m-d H:i:s', strtotime(time()))), $this->language->get('email_subject')), ENT_QUOTES, 'UTF-8'));
Then, find:

Code: Select all

$_['email_subject']  = 'Enquiry %s';
replace with:

Code: Select all

$_['email_subject']  = 'Enquiry: {posted_name} - For Product Name: {product_name} - On: {posted_date}';
This should provide more details to the email subject as expected.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by designbuyers » Thu Feb 02, 2012 12:20 am

straightlight ,
I've try it but seems still do not send the product name in the email.

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by straightlight » Thu Feb 02, 2012 12:30 am

And you've checked the subject line, not only the body ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by designbuyers » Thu Feb 02, 2012 12:55 am

Yes, it didn't show in subject or body ..

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by straightlight » Thu Feb 02, 2012 12:59 am

Since I can't reproduce this particular problem, let's say I would ask you to make a small replacement in the XML file:

Code: Select all

$_['email_subject']  = 'Enquiry: {posted_name} - For Product Name: {product_name} - On: {posted_date}';
to read:

Code: Select all

$_['email_subject']  = 'Enquiry: {posted_name} | Enquiry - For Product Name: {product_name} - On: {posted_date}';
Which would be added with | Enquiry as a prefix to see if you do notice this prefix as a simple text, if you try another email, can you actually see this new added prefix name amongst the subject ? If not, then this is obviously another VQMod XML initialization conflict issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by designbuyers » Thu Feb 02, 2012 2:20 am

It's still same you may try the xml file in attachment

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by straightlight » Thu Feb 02, 2012 2:35 am

Like I said above, I can't reproduce this problem with all XML files disabled except this one.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by designbuyers » Thu Feb 02, 2012 2:43 am

OK, here is first part of the code, edited as you said.

Code: Select all

<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> about {product_name}';
$_['entry_email']    = 'E-Mail Address:';
$_['entry_enquiry']  = 'Enquiry:';
$_['email_subject']  = 'Enquiry: {posted_name} | Enquiry - For Product Name: {product_name} - On: {posted_date}';
$_['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>


OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by straightlight » Thu Feb 02, 2012 2:50 am

It does seem you edited the line correctly but as mentioned above, if you see no effect before and after those changes, then this problem is definitely related to XML initialization conflict issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by designbuyers » Thu Feb 02, 2012 3:04 am

I did see it on vQmod cached files that files has been replaced. but no effect on actual site... I am not sure what's the problem.

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by GoGo OpenCart » Thu Feb 02, 2012 11:45 pm

Here's a module that does that:

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

Demo: http://www.youtube.com/watch?v=f8xFJ4SA57I

Just see the demo, and you'll get the idea ;)

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by designbuyers » Fri Feb 03, 2012 12:07 am

This thread about vQmod.

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by muchio » Thu May 17, 2012 2:11 pm

OC version 1.5.2.1

I've incorporated all modifications mentioned above.
Mail dispatched successfully.
Subject line contains plain text Enquiry Marius (I entered my name into "Your name" field on product page) and actual text as posted in textarea field.
Below is the output of cached AskQuestion.xml part:

Code: Select all

  <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>
No additional vQmods are being used.
I can provide additional info if needed.

Newbie

Posts

Joined
Thu May 17, 2012 1:53 pm

Post by designbuyers » Thu May 17, 2012 11:51 pm

We actually talking about product name not customer name or your name.

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by muchio » Wed May 23, 2012 9:25 pm

Don't get me wrong, but I was saying that data entered into the inquiry form (i.e. name, e-mail and message with the product information) has been emailed incomplete.
Name and message was what's left of it.

Cheers!

Newbie

Posts

Joined
Thu May 17, 2012 1:53 pm

Post by tsd » Mon Aug 20, 2012 9:59 pm

Hi all,
I worked the last day to improve this very useful extension.
I thank 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

Thanks.

tsd
Newbie

Posts

Joined
Sat Aug 18, 2012 6:32 pm

Post by PixImage » Thu Sep 06, 2012 6:46 am

Works fine, but have some errors. (v1.5.3.1 Dutch Language)

PHP Notice: Undefined variable: text_location in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 10
PHP Notice: Undefined variable: text_address in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 12
PHP Notice: Undefined variable: store in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 13
PHP Notice: Undefined variable: address in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 14
PHP Notice: Undefined variable: telephone in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 16
PHP Notice: Undefined variable: fax in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 21
PHP Notice: Undefined variable: text_contact in /customers/b/b/4/mystore.com/httpd.www/catalog/view/theme/default/template/information/contact.tpl on line 28

Do you know how to fix this?

Thx

Newbie

Posts

Joined
Sat Sep 01, 2012 12:12 am

Post by matteoraggi » Thu Jan 17, 2013 9:41 pm

I think that it's better to include the product url , because it's unique, and with a click you can fidn the product, instead with product name, then oyu have to copy and past it and go to search for it.

http://www.restaurantsupplies.eu Restaurant Supplies
Opencart 1.5.6.4 VQMOD 2.4.1
Languages: Italian, French, German, Hungarian, English, Russian, Polish and Spanish


Active Member

Posts

Joined
Fri Apr 10, 2009 8:16 pm
Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 29 guests