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.
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
with
This wil auto-approve every review.
In catalog/controller/product/product.php, add
right below
This wil send an email to the shop owner when a review has been submitted.
Grtz,
Bart
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()");
}
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()");
}
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();
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');
Grtz,
Bart
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!
http://www.opencart.com/index.php?route ... on_id=4828
Hope it helps someone!
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
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
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?benjamin wrote:I have further improved the code to use the shop configuration instead of hardcoding the email, shop name, etc. ...
Who is online
Users browsing this forum: No registered users and 21 guests