Post by abmcr » Fri Aug 07, 2009 4:18 pm

When a review of a product is created by an user, an email was send to the admin email of store.
Small lines: i no post the file sbecause if you have made some modifications it is easy to insert these lines

1) in your catalog/language/product/product.php insert

Code: Select all

$_['text_email']       	 = 'An user (email: %s) has write a review for a productt (%s); your email is set as sending';
$_['subject_text_email'] = "Review insert";
NB: change the text but insert the two palceholder: the first insert the email of the user, the last the URL (not SEO) of the product reviewed

2) at line 351 ofcatalog/controller/product.php insert this code

Code: Select all

		//aggiunta per invio email
		$mail = new Mail();
		$mail->setFrom($this->request->post['email']);
  		$mail->setTo($this->config->get('config_email'));
  		$mail->setSender($this->config->get('config_store'));
  		$mail->setSubject($this->language->get('subject_text_email'));
  		$mail->setText(sprintf($this->language->get('text_email'), $this->request->post['email'],HTTP_SERVER."index.php?route=product/product&product_id=".$this->request->get['product_id']));
  		$mail->send();
		//fine aggiunta
And in the theme/template/product/product.tpl add

Code: Select all

  <!--START-->
      <b><?php echo $entry_email; ?></b><br />
      <input type="text" name="email" value="" />
      <br />
 	  <!--END-->
after these lines (line 100)

Code: Select all

<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-bottom: 10px;"><b><?php echo $entry_name; ?></b><br />
      <input type="text" name="name" value="" />
      <br />
and change at the end of the template file the review function
in

Code: Select all

function review() {
	$.ajax({
		type: 'post',
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val())+ '&email=' + ($('input[name=\'email\']').val()),

		beforeSend: function() {
			$('.success, .warning').remove();
			$('#review_button').attr('disabled', 'disabled');
			$('#review_title').after('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#review_button').attr('disabled', '');
			$('.wait').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review_title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=\'name\']').val('');
				$('input[name=\'email\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
}

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by littleredcar » Thu Sep 17, 2009 7:23 am

hi there.

did everything you said, but NO email is beeing generated to the shop-admin! :-[ and i always get a message saying "Error: E-Mail from required!" at the top of my review form! :-[

dont i have to edit "catalog/model/catalog/review.php", too?
where EXACTLY do i have to copy the "aggiunta per invio email" code in the "catalog/controller/product.php" file (after / before WHAT)?

looking forward to your help - this function really would be very useful to me!

thanks, C A R

---
Environment
php: 7.4.33
Browser: Chrome latest

---
OpenCart
2.3.0.2 singlestore (bugfree edition by xxvirusxx: https://github.com/condor2/Opencart_2302)
DE language by OSWorX (https://www.opencart.com/index.php?rout ... n_id=31048)
Template: Sellmore by 321cart
quite a few Extensions :-)


Active Member

Posts

Joined
Thu Jul 30, 2009 4:21 pm

Post by abmcr » Thu Sep 17, 2009 2:55 pm

IN the product.php controller the new function write is

Code: Select all

public function write() {
    	$this->language->load('product/product');
		
		$this->load->model('catalog/review');
		
		$jason = array();
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
			$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
    		
			$json['success'] = $this->language->get('text_success');
		} else {
			$json['error'] = $this->error['message'];
		}	
		//aggiunta per invio email
		$mail = new Mail();
		$mail->setFrom($this->request->post['email']);
  		$mail->setTo($this->config->get('config_email'));
  		$mail->setSender($this->config->get('config_store'));
  		$mail->setSubject($this->language->get('subject_text_email'));
  		$mail->setText(sprintf($this->language->get('text_email'), $this->request->post['email'],HTTP_SERVER."index.php?route=product/product&product_id=".$this->request->get['product_id']));
  		$mail->send();
		//fine aggiunta
		$this->load->library('json');
		
		$this->response->setOutput(Json::encode($json));
	}
NB: the code is for 1.3.0
I have not tested on >1.3.0

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by myopen » Thu Sep 17, 2009 4:05 pm

hello .. you are always great! .... congratulations for the change ..

I just wanted to know if it works with version 1.3.2 of OpenCart.

(PS: why do not you posted the same change also in Italy forum?)

through 1000

New member

Posts

Joined
Fri Aug 14, 2009 9:27 pm

Post by abmcr » Thu Sep 17, 2009 5:05 pm

TRy with 1.3.2 ... may be work

IN the italian forum http://www.opencart.it/phpBB3/viewtopic.php?f=10&t=122


Ciao

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by banane » Thu Sep 17, 2009 7:07 pm

thanks abmcr
yes, it's working with 1.3.2
I've set the email input as hidden with a default value, so the customer doesn't have to entry his email address
there just a thing a little bit strange: every time I enter a review I receive two confirmation email, not just one

User avatar
New member

Posts

Joined
Fri Jul 31, 2009 6:30 pm


Post by abmcr » Thu Sep 17, 2009 9:03 pm

The correct code for the write function in product.php controller is

Code: Select all

public function write() {
    	$this->language->load('product/product');
		
		$this->load->model('catalog/review');
		
		$jason = array();
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
			$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
    		//aggiunta per invio email
			$mail = new Mail();
			$mail->setFrom($this->request->post['email']);
  			$mail->setTo($this->config->get('config_email'));
  			$mail->setSender($this->config->get('config_store'));
  			$mail->setSubject($this->language->get('subject_text_email'));
  			$mail->setText(sprintf($this->language->get('text_email'), $this->request->post['email'],HTTP_SERVER."index.php?route=product/product&product_id=".$this->request->get['product_id']));
  			$mail->send();
			//fine aggiunta
			$json['success'] = $this->language->get('text_success');
		} else {
			$json['error'] = $this->error['message'];
		}	
		
		$this->load->library('json');
		
		$this->response->setOutput(Json::encode($json));
	}
Try please and send me a response! Ciao

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by littleredcar » Thu Sep 17, 2009 11:27 pm

sorry, guys. found a much more simple solution to this - works like a dream:
http://www.opencart.com/forum/viewtopic.php?f=10&t=5647

C A R

---
Environment
php: 7.4.33
Browser: Chrome latest

---
OpenCart
2.3.0.2 singlestore (bugfree edition by xxvirusxx: https://github.com/condor2/Opencart_2302)
DE language by OSWorX (https://www.opencart.com/index.php?rout ... n_id=31048)
Template: Sellmore by 321cart
quite a few Extensions :-)


Active Member

Posts

Joined
Thu Jul 30, 2009 4:21 pm

Post by abmcr » Fri Sep 18, 2009 1:16 am

Y
littleredcar wrote:sorry, guys. found a much more simple solution to this - works like a dream:
http://www.opencart.com/forum/viewtopic.php?f=10&t=5647

C A R
Yes it is true, but my contribution permti to get also the email of the reviwer ;-)

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm
Who is online

Users browsing this forum: No registered users and 3 guests