How to Fix the Product Return Email Notifications in OpenCart -

There have been reports that the emails for product returns are not working as expected.

In OpenCart - the emails are sent only by the main store even in a multi-store scenario.

As for the ones in OpenCart -, they are not being sent to customers at all.

Well, the good news is that this is fixed in the GitHub repository for the next version of OpenCart.

So, the only choice we have is to give you the fix right here, right now for your current OpenCart version.


The Problem… (For OpenCart -

So, when you click on Add History here, the email to the customer will not be sent, even if the Customer Notified field says “Yes”.

The Problem… (For OpenCart -

The email is being sent, but you cannot change the Sender email address and it will always be sent from the main store email, even if you’re running a multi-store setup.

The store name in the fields "From" and in the mail subject are also fixed.


The Fix for OpenCart -

There are two small files you need to install in your setup to resolve this issue.

The first one is an .SQL file that you need to upload via your web hosting control panel.

IMPORTANT NOTE: Where you have the `oc_event`, replace oc_ with your database table prefix. You can find it in your config.php file.


DELETE FROM `oc_event` WHERE `trigger`='admin/model/sale/return/addReturnHistory/after' AND `action`='mail/return';

INSERT INTO `oc_event` SET `code`='admin_mail_return_history', `trigger`='admin/model/sale/return/addReturnHistory/after', `action`='mail/return', `status`=1, `sort_order`=0;


Copy that code and paste it into a text editor (like Notepad++, Dreamweaver, etc.).

Save the file and name it return_email_fix_oc3_event.sql.

Now, go to your web hosting control panel. For our example, we will be using cPanel.

First Step

Login and go to phpMyAdmin.


Second Step

  1. Select your Database

  2. Click Import

  3. Click Choose File



Third Step

  1. Upload the .SQL file you just saved.

  2. Click Go.


That’s done. The next file is a small modification.

Again, copy this code and paste it into your text editor:


<?xml version="1.0" encoding="utf-8"?>
    <name>Fix: Return E-mail is Multistore (for OpenCart -</name>
    <file path="admin/{model/sale,controller/mail}/return.php">
        <operation error="skip">
            <!-- Hooks in OpenCart 2.x, skipped in OpenCart 3.x -->
            <search><![CDATA[$subject = sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $return_id);]]></search>
            <add position="replace"><![CDATA[
                $order_id = $return_query->row['order_id'];


                $order_info = $this->model_sale_order->getOrder($order_id);

                $store_id = (int)$order_info['store_id'];


                $store_name = $this->model_setting_setting->getSettingValue('config_name', $store_id);
                $store_email = $this->model_setting_setting->getSettingValue('config_email', $store_id);

                $subject = sprintf($this->language->get('text_subject'), html_entity_decode($store_name, ENT_QUOTES, 'UTF-8'), $return_id);]]></add>

        <operation error="skip">
            <!-- Hooks in OpenCart 3.x, skipped in OpenCart 2.x -->
            <search><![CDATA[$data['comment'] = strip_tags(html_entity_decode($comment, ENT_QUOTES, 'UTF-8'));]]></search>
            <add position="after"><![CDATA[
                $order_id = $return_info['order_id'];


                $order_info = $this->model_sale_order->getOrder($order_id);

                $store_id = (int)$order_info['store_id'];


                $store_name = $this->model_setting_setting->getSettingValue('config_name', $store_id);
                $store_email = $this->model_setting_setting->getSettingValue('config_email', $store_id);]]></add>

        <operation error="skip">
            <!-- Hooks in OpenCart 3.x, skipped in OpenCart 2.x -->
            <search><![CDATA[$mail->setSubject(sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $return_id));]]></search>
            <add position="replace"><![CDATA[$mail->setSubject(sprintf($this->language->get('text_subject'), html_entity_decode($store_name, ENT_QUOTES, 'UTF-8'), $return_id));]]></add>

        <operation error="skip">
            <!-- Hooks in all OpenCarts -->
            <add position="replace"><![CDATA[$mail->setFrom($store_email);]]></add>

        <operation error="skip">
            <!-- Hooks in all OpenCarts -->
            <search><![CDATA[$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));]]></search>
            <add position="replace"><![CDATA[$mail->setSender(html_entity_decode($store_name, ENT_QUOTES, 'UTF-8'));]]></add>


Save the file and name it install.xml.

Next, compress the file into a .ZIP and remove the XML part of the name so the file is called

Now, go to your OpenCart dashboard, then Extensions > Installer and upload the .ZIP there.

Now go to Extension > Modifications and click the Refresh button.

That's it.

After implementing these changes, your OpenCart store will be properly sending the customer notifications for product returns via email.


‚ÄčThe Fix for OpenCart -

If your OpenCart store is running one of those versions, then you will be having problems with the Sender email address, as well as the email subject and “From” field when you process product returns and send customer notifications.

The file you need to use is just the modification, NOT the .SQL file.

So, copy and paste the code from the modification above into a text editor.

This time, you can just name the file return_email_fix.ocmod.xml.

Go to your OpenCart dashboard, go to Extensions > Extension Installer and upload the .XML file there.

Next, go to Modifications and hit the Refresh button.

And you’re all done!

These fixes should resolve any issues with the emails that your store should be sending to customers when you’re processing their Product returns in OpenCart to

Join 11,000+ subscribers receiving actionable E-commerce advice

* Unsubscribe any time
comments powered by Disqus