Post by g3niuse » Wed Nov 17, 2021 2:46 am

When I use returns tab in sales and select notify customer email isn't send to customer. I tried to apply fix from git hub which was linked in some other oc forum post (https://github.com/opencart/opencart/co ... 12f0b516af) but that didin't fix a problem. I am running open cart 3.0.3.3.
Thanks for help.

Newbie

Posts

Joined
Tue May 19, 2020 12:55 am

Post by straightlight » Wed Nov 17, 2021 8:03 am

g3niuse wrote:
Wed Nov 17, 2021 2:46 am
When I use returns tab in sales and select notify customer email isn't send to customer. I tried to apply fix from git hub which was linked in some other oc forum post (https://github.com/opencart/opencart/co ... 12f0b516af) but that didin't fix a problem. I am running open cart 3.0.3.3.
Thanks for help.
Error logs. Check your OC admin > extensions > events list and your email configurations in your OC admin > systems > settings > edit settings > Mail tab.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Wed Nov 17, 2021 7:59 pm

There are a lot of things that can cause email issues.

Are other emails from the site sending ok?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by by mona » Wed Nov 17, 2021 11:26 pm

I think it is a problem in 3.0.3.3.
Check the event trigger for return mail from admin in events list:
admin_mail_return

upon install it reads:

Code: Select all

admin/model/sale/return/addReturn/after
should it not be:

Code: Select all

admin/model/sale/return/addReturnHistory/after

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by g3niuse » Thu Nov 18, 2021 11:03 pm

paulfeakins wrote:
Wed Nov 17, 2021 7:59 pm
There are a lot of things that can cause email issues.

Are other emails from the site sending ok?
Every other email is working alright for orders and notification for changing status of order works perfectly fine.
I don't know if affiliate mails are working because i don't use them.

Newbie

Posts

Joined
Tue May 19, 2020 12:55 am

Post by g3niuse » Thu Nov 18, 2021 11:06 pm

by mona wrote:
Wed Nov 17, 2021 11:26 pm
I think it is a problem in 3.0.3.3.
Check the event trigger for return mail from admin in events list:
admin_mail_return

upon install it reads:

Code: Select all

admin/model/sale/return/addReturn/after
should it not be:

Code: Select all

admin/model/sale/return/addReturnHistory/after
It reads like this

Code: Select all

admin/model/sale/return/addReturn/after
but I am not sure how to change that.
Thanks for Help

Newbie

Posts

Joined
Tue May 19, 2020 12:55 am

Post by xxvirusxx » Thu Nov 18, 2021 11:09 pm

g3niuse wrote:
Thu Nov 18, 2021 11:06 pm
but I am not sure how to change that.
Thanks for Help
From phpMyAdmin, xx_event table

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by g3niuse » Thu Nov 18, 2021 11:36 pm

I changed event to trigger at

Code: Select all

admin/model/sale/return/addReturnHistory/after
Emails still don't work and now history in return isn't updated with click on add history when notify is selected but will be updated when I refresh page

Newbie

Posts

Joined
Tue May 19, 2020 12:55 am

Post by by mona » Fri Nov 19, 2021 11:17 pm

well, you could check if the email is now triggered correctly:

in admin/controller/mail/return.php

you add:

Code: Select all

$this->log->write('About to send an email for return: '.$return_id.' to '.$return_info['email']);
right after:

Code: Select all

$mail->setTo($return_info['email']);
Then add a return history again with notify and check your oc error log whether that message is there.

if it is, the trigger is ok, if you still do not get an email, you have an email processing issue.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by g3niuse » Sat Nov 20, 2021 4:07 am

I finally found solution for this problem.
First you need to change event to

Code: Select all

admin/model/sale/return/addReturnHistory/after
When you have done that in admin/controller/mail/return.php
You need to delete this lanes if you implemented the fix from github

Code: Select all

$language_info = $this->model_localisation_language->getLanguage($return_info['language_id']);
if ($language_info) {
	$language_code = $language_info['code'];
} else {
	$language_code = $this->config->get('config_language');
}
You need to delete this because of some reason this can't get language code
Then you need to change line

Code: Select all

$language = new Language($language_code);
$language->load($language_code);
$language->load('mail/return');
Into

Code: Select all

$language = new Language('en-gb');
$language->load('en-gb');
$language->load('mail/return');
I know that this is hard coded but I didn't find other solution . You need to change en-gb to your language code if u don't use English
This part is so funny because someone forgot to add all data needed for email body
After this lines

Code: Select all

$data['return_id'] = $return_id;
$data['date_added'] = date($language->get('date_format_short'), strtotime($return_info['date_modified']));
$data['return_status'] = $return_info['return_status'];
$data['comment'] = strip_tags(html_entity_decode($comment, ENT_QUOTES, 'UTF-8'));
You need to add this

Code: Select all

$data['text_return_id']=$language->get('text_return_id');
$data['text_date_added']=$language->get('text_date_added');
$data['text_return_status']=$language->get('text_return_status');
$data['text_comment']=$language->get('text_comment');
$data['text_footer']=$language->get('text_footer');
And that should fix emailing problem for returns.
In the end complete file should look like this

Code: Select all

<?php
class ControllerMailReturn extends Controller {
	public function index($route, $args, $output) {
		if (isset($args[0])) {
			$return_id = $args[0];
		} else {
			$return_id = '';
		}
		
		if (isset($args[1])) {
			$return_status_id = $args[1];
		} else {
			$return_status_id = '';
		}		
		
		if (isset($args[2])) {
			$comment = $args[2];
		} else {
			$comment = '';
		}
		
		if (isset($args[3])) {
			$notify = $args[3];
		} else {
			$notify = '';
		}		
		
		if ($notify) {
			$this->load->model('sale/return');
			
			$return_info = $this->model_sale_return->getReturn($return_id);
			if ($return_info) {    

				$language = new Language('en-gb');
				$language->load('en-gb');
				$language->load('mail/return');
				$data['return_id'] = $return_id;
				$data['date_added'] = date($language->get('date_format_short'), strtotime($return_info['date_modified']));
				$data['return_status'] = $return_info['return_status'];
				$data['comment'] = strip_tags(html_entity_decode($comment, ENT_QUOTES, 'UTF-8'));
				$data['text_return_id']=$language->get('text_return_id');
				$data['text_date_added']=$language->get('text_date_added');
				$data['text_return_status']=$language->get('text_return_status');
				$data['text_comment']=$language->get('text_comment');
				$data['text_footer']=$language->get('text_footer');


				$mail = new Mail($this->config->get('config_mail_engine'));
				$mail->parameter = $this->config->get('config_mail_parameter');
				$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
				$mail->smtp_username = $this->config->get('config_mail_smtp_username');
				$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
				$mail->smtp_port = $this->config->get('config_mail_smtp_port');
				$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');

				$mail->setTo($return_info['email']);
				$mail->setFrom($this->config->get('config_email'));
				$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
				$mail->setSubject(sprintf($language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $return_id));
				$mail->setText($this->load->view('mail/return', $data));
				$mail->send();
			}
		}
	}
}	
Huge thanks to mona

Newbie

Posts

Joined
Tue May 19, 2020 12:55 am

Post by KaleStud » Wed Nov 20, 2024 1:16 am

In a new installation of 3.0.3.8 all of a sudden my customers didn't get a confirmation of their RMA's.
I tried all fixes I could find but to no avail.
In the end I purchased this extension that was the solution for me:
https://www.opencart.com/index.php?rout ... n_id=44589
You can switch admin E-mails and customer-emails on and off or both. It is multilingual and uses html for styling.
I'm happy with it and it works like a charm.

Newbie

Posts

Joined
Thu Mar 09, 2017 11:17 pm
Who is online

Users browsing this forum: No registered users and 16 guests