From the author: Greetings, friends. So, we continue the series of articles devoted to getting to know one of the most popular CMS for creating online stores - OpenCart. In this article we will talk about how to set up email in OpenCart.

One of required functions in OpenCart is sending mail. After each order placed, information about it should be sent to the site manager by email so that he can promptly process the received order. It is also advisable to send a letter to the client about the completed order, this will be good manners towards the client. Let's see how and where to set up mail in OpenCart.

As you understand, this is done in the admin panel, where we go. Go to the System – Settings menu and go to edit store settings. Here we are primarily interested in the Showcase tab. Open it and find the E-Mail field.

There is already an email address here, this is the address that was specified when installing the engine. If it is suitable for notifications from the site, then leave it; if it is not suitable, then indicate another one instead.

Great! Now all notifications from the site should be sent to this email. Just in case, be sure to test this point by creating a test order. If you receive an email with order details, then everything is working. If there is no letter (be sure to check the Spam folder), then you can try to specify another mailbox, preferably on a different domain. If there is the same problem with the second mailbox, then, most likely, the mail function is disabled on your hosting and the letters are simply not sent.

It doesn’t matter, there is a solution for this situation. On the same page for editing settings there is a Mail tab, go to it.

This tab allows you to configure mail sending using the SMTP protocol. To do this, you must have a mailbox that allows you to send mail from mail clients. For example, this could be a mailbox yandex.ru, mail.ru, gmail.com, ukr.net and others. You need in settings mailbox Allow sending mail from mail clients and get SMTP settings: host and port. All necessary settings you enter in the fields provided, following the prompts. Instead of Mail, select SMTP as the mail protocol. To make it clearer how to work with SMTP, I recommend looking at it, from it you will understand what these settings are and how to use them.

On October 28, 2019, new versions of the module for sending notifications from OpenCart/ocStore were published, which fixed a bug with incorrect work sender name selector if the client/partner has more than 1 sender name. If you use more old version module, we recommend reinstalling the module.

If our module is not installed according to the standard procedure described below, then this is most likely due to the use of a non-standard template, edits to engine files, or due to the use of modules that use modifiers. In this case, contact our support and they will help you install a module for sending SMS/Email notifications.

Using the mailing integration module "site: SMS/Email mailings and notifications" and OpenCart/ocStore, you can send SMS and Email notifications for specified events to the administrator and customers of the online store.

2.Compatibility

  1. OpenCart: 2.0, 2.1, 2.2, 2.3, 3.0
  2. ocStore: 2.1, 2.2, 2.3, 3.0

3.Functional

  1. Automatic SMS/Email notification to administrators (one or more) of the online store about the appearance of a new order (sending Email is supported only for version 3.0)
  2. Automatic sending SMS/Email messages to online store users when order statuses change
  3. Ability to configure any mode for sending notifications: only SMS, only Email, or SMS and Email together
  4. Sending arbitrary SMS messages to any number from the module settings
  5. Sending arbitrary SMS messages from order cards
  6. Support for SMS/Email message templates (for example, notification of a new order, change of order status, and much more), including standard and personalized ones
  7. Opportunity flexible settings notifications: You can set up SMS/Email notifications only for certain order statuses
  8. Personalization of texts of SMS/Email messages (including subject line)
  9. Account balance online
  10. Saving the history of sent SMS/Email messages
  11. Ability to send Email via our SMTP server
  12. Filtering incorrect phone numbers (long, short);
  13. Recognition of phone numbers in a variety of formats, for example, +79001234567, 79001234567, 89001234567, etc.;
  14. Ignoring non-mobile phone numbers;
  15. Automatic download used sender names from your personal SMS mailing account sms.site;
  16. Sending SMS to subscribers all over the world (Russia, Ukraine, Belarus, Kazakhstan, etc.) and much more.

4.Activation ( using ocStore 2.3 as an example.)

5.Settings


6.Features of installing the module for Opencart/ocStore 3.0

As you know, OpenCart/ocStore 3.0 does not have the ability to install files in the system folder (and we need this), so:

  1. First you need to download and install the downloaded module in the OpenCart/ocStore admin panel in the "Install add-ons" menu item





  2. After that, go to “Modifiers” and click the “Update” button

  3. Next, install the targetsms-opencart-3.0.ocmod.zip module (version that supports sending only SMS notifications) or the targetsms_email-opencart-3.0.ocmod.zip module (version that supports sending both SMS and Email notifications) exactly like this the same as described in the example for version OpenCart/ocStore 2.3. higher.











7.Creating a template for an SMS message about a new order for online store administrators


8.Creating templates for SMS messages about order statuses for online store customers

  1. Open the "Buyer SMS Templates" tab
  2. Enter the texts of SMS message templates for activated statuses using personalization parameters, if necessary

9.Creating a template for an email message about a new order to online store administrators


10.Creating email templates about order statuses for online store customers

  1. Open the "Buyer Email Templates" tab
  2. Activate the order statuses you need by checking the boxes
  3. Fill in the topics and enter the texts of the email templates for activated statuses using personalization parameters, if necessary
  4. Click the "Save" button at the top right

11.Template support

  1. In processing
  2. Return
  3. Refunded
  4. Delivered
  5. Failed
  6. Expectation
  7. Cancellation and annulment
  8. Canceled
  9. Completely changed
  10. Full return
  11. The deal is completed
  12. And also: SMS templates for arbitrary (custom) statuses

12.Personification of texts of SMS/Email messages

The following personification variables are available in the message text:

  1. (CUSTOMER_NAME) - full name of the buyer
  2. (CUSTOMER_FIRSTNAME) - customer name
  3. (CUSTOMER_LASTNAME) - buyer’s last name
  4. (CUSTOMER_EMAIL) - buyer’s email
  5. (CUSTOMER_PHONE) - buyer’s phone number
  6. (NUMBER) - order number
  7. (TOTAL_ORIGINAL_PRICE) - order cost without discount
  8. (TOTAL_PRICE) - order cost
  9. (TOTAL_AMOUNT) - quantity of goods
  10. (STATUS_CHANGE_DATE) - date last change status
  11. (ORDER_DATE) - order date
  12. (ORDER_DISCOUNT_VALUE) - discount amount on the order
  13. (DELIVERY_PRICE) - delivery cost
  14. (COMMENT_ADMIN) - "Comment" field (for example, to insert an order postal track)

13.Sending a custom SMS message from the module settings

  1. Open the "Send SMS" tab
  2. Enter the recipient's phone number and message text
  3. Click the "Submit" button

14.Sending a custom SMS message from the order card

  1. Open the card of the order you need
  2. At the very bottom of the page in the "Message" field, enter the SMS text you need
  3. Click the "Send" button (the sender's name will be automatically taken from the module settings, the buyer's phone number will be taken from the order card)

15.SMS history

You can view the history of sent SMS messages on the "SMS History" tab.

16.Email History

You can view the history of sent email messages in personal account SMS mailings sms..

17.Replenishment of SMS balance

You can check and top up your balance on the "Settings" tab

18.Typical problems and difficulties

The most popular problems and questions regarding working with integration are described.

Test messages for free

I’m just getting to grips with Opencart 3 and I don’t really like installing incomprehensible add-ons, but I like to disassemble and study everything, and after the site was launched for the client and on the same day after the first order, it was decided to rework the letter that the admin and manager receive about the order, namely, what would the letter say:

  • surname
  • telephone
  • address
  • city
  • payment method
  • delivery method

In total, you need all the fields that the buyer fills in on the site.

In the end, this is what I came to.

When a client places an order, he receives a letter with all the information:

whereas the administrator receives such a sad letter (((


Well, as you understand, or rather, anyone who has ever run their own online stores will immediately say that it’s no good, don’t call or find out any information in order to get more detailed information you need to log into the admin panel, but what if you are on the road and can’t log into the admin panel?

Well, in the end, I went the other way and simply replaced the letters, i.e. the admin will receive the same letter as the client)

and now a little magic and it's in the bag)

Opencart 3 letter to admin about order

In order for opencart to receive a letter to the admin about an order with all the information in the letter, you need to edit two files:

  1. /catalog/controller/mail/ order.php
  2. /catalog/view/theme/yourtheme/template/mail/ order_alert.twig

order.php

Open the file order.php and look for line 270 where there is this text:

$mail->setTo($order_info[’email’]);
$mail->setFrom($from);
$mail->
$mail->setSubject(html_entity_decode(sprintf($language->get('text_subject'), $order_info['store_name'], $order_info['order_id']), ENT_QUOTES, 'UTF-8'));
$mail->setHtml($this->load->view(‘mail/order_add’, $data));
$mail->send();

Below it we paste this code:

$mail->setTo($this->config->get(‘config_email’));
$mail->setFrom($this->config->get(‘config_email’));
$mail->setSender(html_entity_decode($order_info[‘store_name’], ENT_QUOTES, ‘UTF-8’));
$mail->setSubject(html_entity_decode(sprintf($this->language->get('text_subject'), $this->config->get('config_name'), $order_info['order_id']), ENT_QUOTES, ' UTF-8'));
$mail->setHtml($this->load->view(‘mail1/order_alert’, $data));
$mail->send();

This insert The code was inserted into the section where a letter is generated and sent to the buyer, and we also send the same letter to the administrator. As you can see, we substituted a letter template order_alert )))

order_alert.twig

What we did above will not actually change anything, we will still receive the same miserable letter, and all because we have not yet changed the letter template that should be sent to the administrator!

Look, I did everything on the standard Opencart template with the default theme, and therefore I created the mail1 folder specifically for this and in it we create the order_alert.twig file, if you have your own theme, then just create the mail folder if it’s not there

The data for the order_alert.twig file is completely copied from the file order_add.twig (which is located at /catalog/view/theme/default/template/mail)

After that, we will receive the following letter in the mail)


Well, as usual video))

There are no similar entries.

The customer set the task to change incoming message to the admin's email. Sending email messages to opencart. I thought it was a very simple task, but it took me 2 days. The first difficulty arose when sending mail to mail.ru. For some reason messages on this postal service they just didn't come.

So I got the task. Then I started setting up opencart and changed the email settings for the site and for the admin. I started testing, but the messages did not arrive. Until the moment of change, I tried the form just out of curiosity. The customer wrote that the message had arrived, but the essence of his task was to change the header of the letter from: email, in other words, he received messages with the sender's mail and the recipient's mailing address.

I don’t know why this picture is needed at all, but oh well.

Opencart messages are not coming

And so the customer wrote off the mail, but after changing the mailing address to a resource from mail.ru, I couldn’t receive the letter, I won’t write to the customer that I don’t understand what’s going on. It ended up taking a whole day to do this. I still didn’t understand what the question was, I just changed the mailing address to Yandex.

The next moment I was completely confused about where everything came from, even though I was already working on opencart. The next day was spent understanding the structure of the CMS.

Main submission file:

system\library\mail.php

By analogy, we find similar fields in contact.tpl and duplicate them. Then we find the controller contact.php the same name only php extension. In this case it was written in the line

$mail->setFrom($this->config->get("config_email"));

Replaced with

$mail->setFrom($this->request->post["email"]);

If you need to pass values ​​from the form to the body of the letter, then add them to the controller

$mail->setText($this->request->post["name"]); $mail->setText($this->request->post["phone"]); $mail->setText($this->request->post["subject"]);