Post by dizarter » Sat Oct 22, 2011 4:46 am

I am amazed a version of this has not been implemented yet!

I vote that there should be an option in the store admin to enable review notifications on and off.

It will be a huge plus to the product reviewal system.

Just my $0.02 anyways.

New member

Posts

Joined
Tue Oct 11, 2011 7:33 am

Post by baha90210 » Fri Jan 27, 2012 6:51 pm

Hi Guys,

Great job, although I think that the model tier is just for doing database stuff.
The model tier would be a better place to send out mails.

That's why I'm posting another version of the code.

In catalog/model/catalog/review.php, replace

Code: Select all

public function addReview($product_id, $data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "review SET author = '" . $this->db->escape($data['name']) . "', customer_id = '" . (int)$this->customer->getId() . "', product_id = '" . (int)$product_id . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', date_added = NOW()");
	}
with

Code: Select all

public function addReview($product_id, $data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "review SET author = '" . $this->db->escape($data['name']) . "', customer_id = '" . (int)$this->customer->getId() . "', product_id = '" . (int)$product_id . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', status = '1', date_added = NOW()");
	}
This wil auto-approve every review.

In catalog/controller/product/product.php, add

Code: Select all

			$data = $this->request->post;

			$this->load->model('catalog/product');
			$product_info = $this->model_catalog_product->getProduct($product_id);
			
			$message ="<strong>You have a new product review waiting.</strong><br><br>";
			$message.='Product: '.$this->db->escape(strip_tags($product_info['name'])).'<br>';
			$message.='Reviewer: '.$this->db->escape(strip_tags($data['name'])).'<br>';
			$message.='Rating: '.$this->db->escape(strip_tags($data['rating'])).'<br><br>';
			$message.='Text: <br>';
			$message.=$this->db->escape(strip_tags($data['text']))."<br><br>";
			$message.='<a href="'.$this->config->get('config_url').'/admin/index.php">Login to review</a>';
			
			$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
			$mail->setTo(array($this->config->get('config_email')));
			$mail->setFrom($this->config->get('config_email'));
			$mail->setSender($this->config->get('config_name'));
			$mail->setSubject("Product Review");
			$mail->setHtml($message);

			$mail->send();			
right below

Code: Select all

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && !isset($json['error'])) {
			$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
			
			$json['success'] = $this->language->get('text_success');
This wil send an email to the shop owner when a review has been submitted.

Grtz,

Bart

Newbie

Posts

Joined
Fri Jan 27, 2012 5:08 pm

Post by Concept211 » Wed Feb 01, 2012 5:59 am

I went ahead and converted this to a vQmod for v1.5.1.3:
http://www.opencart.com/index.php?route ... on_id=4828

Hope it helps someone!

User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am

Post by URAGANU » Thu May 10, 2012 7:27 pm

Can you adapt it to latest version of OC ?

Thanks for efforts.

Newbie

Posts

Joined
Tue Mar 27, 2012 6:45 am

Post by Wade C » Wed Jun 13, 2012 5:57 am

What would be involved with making a VqMOD like this for getting email notification when a customer submits a return request?

Been reading up on that and seems the only VqMOD out there is for newer versions, and Im not ready to upgrade yet.

Hoping to get email notifications from the system when a customer submits a return. (Honestly, cant believe it needs to be a mod - and not part of the core stuff - but not my baby so not my call either)

Thanks
Wade

New member

Posts

Joined
Sat Apr 11, 2009 1:12 am

Post by Cartyhe » Sat Jul 07, 2012 6:53 am

benjamin wrote:I have further improved the code to use the shop configuration instead of hardcoding the email, shop name, etc. ...
Hi Benjamin. Would you say this works in version 1.5.3.1? I tested it and I get no email, whatsoever. I pasted the bit of code after the ';' so it's between ';' and '}', correct?

New member

Posts

Joined
Wed Jul 04, 2012 1:21 pm
Who is online

Users browsing this forum: No registered users and 3 guests