Post by webpie it. » Wed Aug 03, 2011 2:55 pm

This has been bugging the crap out of me for ages, and before someone says, "build it yourself" i will look into it, & don;t say upgrade as it is not possible for me to do so, as of this moment but:

Why does the admin not receive a notification email when a return has happend?

It doesn't even have to be a substantial email, just you have a returns request waiting, or something like that!

How is the admin suppose to know when a return request has happened, to me this seems there is no point having a returns system unless this happens, because i categorically guarantee the any clients using the system will not actively go a nd check, even if i gave them a bullet point list of things to do everyday when checking the back office, i've already seen it happen. And before someone says some wise crack about having stupid clients, ask yourself what my clients ask me, "why don't i get an email about a return?"

Which has led me here to ask?

It just seems like the most important thing for returns, so it can be processed has been missed out, can anyone shed some light on this or has anyone tried to fix this?

Cheers Guys

Chris
Last edited by webpie it. on Fri Aug 05, 2011 1:31 pm, edited 3 times in total.

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by marcelwoo » Wed Aug 03, 2011 7:17 pm

Hi, Chris. I have been thinking about this for some time. Admin should indeed get email notification when a return request is submitted! But I am not a coder and changing the code is far beyond me.
However, someone in the past made a little mod to notify admin when a new review is inserted.
I hope this will shed some light.
check the post here:

http://forum.opencart.com/viewtopic.php ... dit#p74324

If you have managed to do it, please share the codes if possible.
Lots of people need this notification function, including me :D

Marcel

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by webpie it. » Wed Aug 03, 2011 11:12 pm

Followed you suggestion to look at the old post, basically here at the moment thanks to jcsmithy as usual!:

On V 1.5.0.5 the admin will now get an email if a review is posted about any product.

Inserted this into catalog/model/catalog/review.php

Find:

Code: Select all

<?php
class ModelCatalogReview extends Model {		
	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()");
	}
Add:

Code: Select all

<?php
class ModelCatalogReview extends Model {		
	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()");
		
		 [highlight]$message ="<strong>You have a new product review waiting.</strong><br><br>"
		.$data['text']."<br>"
		.'<a href="http://YOURSITEHERE.COM/">Login to review</a>';
		
		         
		$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("YOUREMAIL@MAIL.COM");
		$mail->setSender("NAME OF SHOP HERE");
		$mail->setSubject("Product Review");
		$mail->setHtml(strip_tags(html_entity_decode($message, ENT_QUOTES, 'UTF-8')));
		$mail->send();[/highlight]

	}
		
UPdate the above parts in the code to your site of course.

Working on the returns one, but as the logic is the same just got to update a few things, but will post when i get it right!

Chris

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by webpie it. » Thu Aug 04, 2011 1:19 am

Ok Got the returns email alert working with masive help from JCSMITHY! AGAIN! lol

Find:

/catalog/controller/account/return.php

Line 312 on mine

Code: Select all

public function insert() {
		$this->language->load('account/return');

		$this->load->model('account/return');

    	if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_account_return->addReturn($this->request->post);
	  		
			$this->redirect($this->url->link('account/return/success', '', 'SSL'));
    	} 
Add below:

Code: Select all

public function insert() {
		$this->language->load('account/return');

		$this->load->model('account/return');

    	if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_account_return->addReturn($this->request->post);
			
			[highlight]$message ="<strong>You have a product return waiting.</strong><br><br>"
					.'<a href="http://YOURWEBSITE.COM/ADMIN">Login to review</a>';
			
					$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("YOUREMAIL@mail.com");
					$mail->setSender("SENDER NAME HERE");
					$mail->setSubject("A Return Has Been Requested");
					$mail->setHtml($message);
					$mail->send();[/highlight]
			
	  		
			$this->redirect($this->url->link('account/return/success', '', 'SSL'));
    	} 
I have tested this on 1.5.0.5 and works perfect!

This should Be all you need!

Thanks JCSMITHY!

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by marcelwoo » Thu Aug 04, 2011 12:21 pm

works like a charm!

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by marcelwoo » Fri Aug 05, 2011 10:17 am

By the way, if you guys want to have email alerts for new affiliate account signed up waiting to be approved.
Do this:

open catalog\controller\affiliate\success.php

Find

Code: Select all

		$this->response->setOutput($this->render());
After it, insert:

Code: Select all

		$message ="<strong>You have a new affiliate waiting to be approved.</strong><br><br>"
               .'<a href="http://www.YOURSITE.com/admin/">Login to review</a>';
         
               $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("YOUREMAIL@YOURSITE.COM");
               $mail->setSender("YOURSITE.com");
               $mail->setSubject("An Affiliate Account Has Been Requested");
               $mail->setHtml($message);
               $mail->send();

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by webpie it. » Fri Aug 05, 2011 1:32 pm

Awesome man thanks, changed the title to include this now!:)

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by kenno » Sun Sep 04, 2011 10:22 pm

webpie it. wrote:Followed you suggestion to look at the old post, basically here at the moment thanks to jcsmithy as usual!:

On V 1.5.0.5 the admin will now get an email if a review is posted about any product.

Inserted this into catalog/model/catalog/review.php

Find:

Code: Select all

<?php
class ModelCatalogReview extends Model {		
	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()");
	}
Add:

Code: Select all

<?php
class ModelCatalogReview extends Model {		
	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()");
		
		 [highlight]$message ="<strong>You have a new product review waiting.</strong><br><br>"
		.$data['text']."<br>"
		.'<a href="http://YOURSITEHERE.COM/">Login to review</a>';
		
		         
		$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("YOUREMAIL@MAIL.COM");
		$mail->setSender("NAME OF SHOP HERE");
		$mail->setSubject("Product Review");
		$mail->setHtml(strip_tags(html_entity_decode($message, ENT_QUOTES, 'UTF-8')));
		$mail->send();[/highlight]

	}
		
UPdate the above parts in the code to your site of course.

Working on the returns one, but as the logic is the same just got to update a few things, but will post when i get it right!

Chris
Hi Chris

So have you applied this change and got this working in your 1.5.05 then, as everytime I try to make this change in catalog/model/catalog/review.php I am hit with this site error

Parse error: syntax error, unexpected '[' in /home/vwgolfm/public_html/shop/catalog/model/catalog/review.php on line 6

Line 6 in that file is where this part of the code starts

Code: Select all

 [highlight]$message ="<strong>You have a new product review waiting.</strong><br><br>"
Any ideas what I could be doing incorrect ?

Here is my review.php file

Code: Select all

<?php
class ModelCatalogReview extends Model {		
	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()");

			[highlight]$message ="<strong>You have a new product review waiting.</strong><br><br>"
      .$data['text']."<br>"
      .'<a href="http://sitename.org.uk/">Login to review</a>';
      
               
      $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("webmaster@sitename.org.uk");
      $mail->setSender("Shop");
      $mail->setSubject("Product Review");
      $mail->setHtml(strip_tags(html_entity_decode($message, ENT_QUOTES, 'UTF-8')));
      $mail->send();[/highlight]

	}
		
	public function getReviewsByProductId($product_id, $start = 0, $limit = 20) {
		$query = $this->db->query("SELECT r.review_id, r.author, r.rating, r.text, p.product_id, pd.name, p.price, p.image, r.date_added FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
		
		return $query->rows;
	}
	
	public function getAverageRating($product_id) {
		$query = $this->db->query("SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review WHERE status = '1' AND product_id = '" . (int)$product_id . "' GROUP BY product_id");
		
		if (isset($query->row['total'])) {
			return (int)$query->row['total'];
		} else {
			return 0;
		}
	}	
	
	public function getTotalReviews() {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) WHERE p.date_available <= NOW() AND p.status = '1' AND r.status = '1'");
		
		return $query->row['total'];
	}

	public function getTotalReviewsByProductId($product_id) {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
		
		return $query->row['total'];
	}
}
?>
I may have done something wrong but I can`t understand what, any help is appreciated mate

I also get a similar error when trying to make the other change for the returns email modification, am i just being stupid :crazy:

Thanks Mark

Newbie

Posts

Joined
Fri Jul 08, 2011 3:31 am

Post by kenno » Fri Sep 09, 2011 3:03 am

Does anyone know of an answer to this or what I am doing wrong if this fix actually works ?

Newbie

Posts

Joined
Fri Jul 08, 2011 3:31 am

Post by uksitebuilder » Fri Sep 09, 2011 3:11 am

For the price of a beer in London my extension does this and also adds alerts to the dashboard

see -> http://www.opencart.com/index.php?route ... order=DESC

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by webpie it. » Fri Sep 09, 2011 3:13 am

Hi mark so sorry for missing this one, i will complete your review.php with mine and see if there is an error, as i can confirm this does work!:)

Get back to you real soon!

Though just saw uksb, i have to agree his mod does this and a lot more.

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by kenno » Fri Sep 09, 2011 3:41 am

Simon (Uksitebuilder)

Are you the same person who assisted me with the start up of my site all them years ago, it is a bulldog forum and I started out on php-nuke and you helped (maybe still do) the mk2 golf owners club.

If not just ignore me.

I have just had a look at your module, which looks very good, and very reasonably priced, but I don`t think I will need to alerts on the dashboard if I can just get the admin email notification for these returns and reviews, if I can`t get the code working then I will buy the module.
But if webpie has got his working with no errors I will have a go that way first

Thanks Mark

Newbie

Posts

Joined
Fri Jul 08, 2011 3:31 am

Post by uksitebuilder » Fri Sep 09, 2011 3:43 am

Hi Mark

Yep, it is I (small world)

I still do a bit for the VWGolf forum guys now and then.

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by kenno » Fri Sep 09, 2011 3:55 am

Yep a very small world ha.
I actually help the mk1 golf owners club and this is who the opencart store is for.

My little site still has that logo you created for it.

Anyway I will get back to you if can`t figure out a fix for this little email issue

Newbie

Posts

Joined
Fri Jul 08, 2011 3:31 am

Post by webpie it. » Fri Sep 09, 2011 4:40 am

Code: Select all

<?php
class ModelCatalogReview extends Model {      
   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()");

         $message ="<strong>You have a new product review waiting.</strong><br><br>"
      .$data['text']."<br>"
      .'<a href="http://sitename.org.uk/">Login to review</a>';
      
               
      $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("webmaster@sitename.org.uk");
      $mail->setSender("Shop");
      $mail->setSubject("Product Review");
      $mail->setHtml(strip_tags(html_entity_decode($message, ENT_QUOTES, 'UTF-8')));
      $mail->send();

   }
      
   public function getReviewsByProductId($product_id, $start = 0, $limit = 20) {
      $query = $this->db->query("SELECT r.review_id, r.author, r.rating, r.text, p.product_id, pd.name, p.price, p.image, r.date_added FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
      
      return $query->rows;
   }
   
   public function getAverageRating($product_id) {
      $query = $this->db->query("SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review WHERE status = '1' AND product_id = '" . (int)$product_id . "' GROUP BY product_id");
      
      if (isset($query->row['total'])) {
         return (int)$query->row['total'];
      } else {
         return 0;
      }
   }   
   
   public function getTotalReviews() {
      $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) WHERE p.date_available <= NOW() AND p.status = '1' AND r.status = '1'");
      
      return $query->row['total'];
   }

   public function getTotalReviewsByProductId($product_id) {
      $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
      
      return $query->row['total'];
   }
}
?>
Ok Mark your fixed file is above, copy that into your review.php

all i have done, which i should have done beofre is remove the [ highlight ][ /highlight ]

Rookie error pointed out by jcsmithy!! lol

Chris

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by kenno » Fri Sep 09, 2011 5:07 am

Amazing, thanks for that I will try this.

What will the issue be with the returns.php, this was giving the same or similar error ?

Newbie

Posts

Joined
Fri Jul 08, 2011 3:31 am

Post by webpie it. » Fri Sep 09, 2011 5:17 am

For returns follow what put i put above about returns.php but where you see[ highlight] and [\ highlight] remove these both and it should work.

Exact same error as review above:

Sorry my mistake!!

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by maranjo » Wed Nov 23, 2011 3:04 am

webpie it. wrote:Ok Got the returns email alert working with masive help from JCSMITHY! AGAIN! lol
...
...

I have tested this on 1.5.0.5 and works perfect!

This should Be all you need!

Thanks JCSMITHY!
Many thanks for this - just added it to my 1.5.1.3 install and it works like a charm.

New member

Posts

Joined
Wed Apr 28, 2010 8:39 pm

Post by Lao » Mon Feb 13, 2012 12:33 am

Strange, it doesn't work for me.

I'm using Open Cart 1.5.4.1 on http://www.importpieseauto.ro


User avatar
Lao
Active Member

Posts

Joined
Tue Nov 23, 2010 3:31 pm
Location - Craiova, Romania

Post by yiyinlah » Sat Feb 25, 2012 12:01 am

I will try on 1.5.1.3 & let you guys know later if it works for me :)

I'm using Opencart 1.5.4.1 & vQmod 2.3.2.


User avatar
Active Member

Posts

Joined
Thu Sep 23, 2010 1:19 pm
Location - Singapore
Who is online

Users browsing this forum: No registered users and 43 guests