OpenCart - Alert on store actions

As I start testing out OpenCart, I ran into one issue. When a customer puts in a request for a return, no email is sent to alert the store admin or any one. So I started looking around for solutions and ran into couple of suggestions on OpenCart forum. Below are my variations which I am contributing to OpenCart community for free as this is not my original work.

Objective: Email alert sent on request for return

Step 1: Look for file

catalog/controller/account/return.php

Step 2: Search for

$this->model_account_return->addReturn($this->request->post);

Step 3: Add after

$message ="<strong>".$this->customer->getFirstName()." ".$this->customer->getLastName()." has submitted a product return request.</strong><br><br>"
               .'<a href="http://'.$_SERVER["SERVER_NAME"].'/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')); /* OR setTo("MYEMAIL@MYDOMAIN.COM"); */
               $mail->setFrom($this->config->get('config_email')); /* OR setFrom("MYEMAIL@MYDOMAIN.COM"); */
               $mail->setSender($this->config->get('config_name'));
               $mail->setSubject(($this->config->get('config_name')) . " - Product Return Request");
               $mail->setHtml($message);
               $mail->send();


Objective: Email alert sent when a new affiliate signs up

Step 1: Look for file

catalog/controller/affiliate/success.php

Step 2: Search for

$this->response->setOutput($this->render());

Step 3: Add after

$message ="<strong>A new affiliate signed up at ".$this->config->get('config_name')." and waiting approval.</strong><br><br>"
               .'<a href="http://'.$_SERVER["SERVER_NAME"].'/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')); /* OR setTo("MYEMAIL@MYDOMAIN.COM"); */
               $mail->setFrom($this->config->get('config_email')); /* OR setFrom("MYEMAIL@MYDOMAIN.COM"); */
               $mail->setSender($this->config->get('config_name'));
               $mail->setSubject(($this->config->get('config_name')) . " - New Affiliate Signup");
               $mail->setHtml($message);
               $mail->send();


As I continue testing OpenCart, I may be able to contribute more. Check out my contributions page where you can find the vQmod version for some of my contributions.

By the way, if you use OpenCart, have you installed vQmod? If not, I recommend you do that right now. Believe me, it's a life saver if you are interested to extend the functionality of your OpenCart site by adding more modules or extensions.

Add new comment

Plain Text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Add new comment

Plain Text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.