Opencart order notification by mail. Sending SMS and Email from OpenCart. Creating an SMS template for a new order for online store administrators

From the author: I greet you friends. So, we continue the series of articles devoted to acquaintance with one of the most popular CMS for creating online stores - OpenCart (Opercart). In this article, we will talk about how to set up mail in OpenCart.

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

As you can imagine, this is done in the admin panel, where we go. Go to the menu System - Settings and go to edit the 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, 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 does not fit, then specify another one instead.

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

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

This tab allows you to configure sending mail using the SMTP protocol. To do this, you must have a mailbox that allows you to send mail from mail clients. For example, it can be mailbox yandex.ru, mail.ru, gmail.com, ukr.net and others. You need to allow sending mail from mail clients in the mailbox settings and get the SMTP settings: host and port. You enter all the necessary settings in the proposed fields, guided by the prompts. Choose SMTP as the mail protocol instead of Mail. To make it clearer how to work with SMTP, I recommend that you look, from it you will understand what these settings are and how to use them.

The customer set the task to change the incoming message to the admin's mail. 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 to this postal service simply did not come.

So I got the task. Then I began to configure opencart and changed the mail settings for the site and for the admin in the settings. Began to test, but messages did not come. Until the moment of change, I tried the form just from the bulldozer. The customer wrote that the message came, but the essence of his task should be changed in the header of the letter from: email, in other words, he received messages with the mail of the sender and the recipient's mail address.

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

Opencart messages are not received

And so the customer unsubscribed the mail I received after changing the postal address to the resource from mail.ru I could not receive the letter in any way, I will not write to the customer that I do not understand what is the matter. In the end, it took a whole day to do it. In what the question did not understand, I just changed the mailing address to yandex.

The next moment there was complete confusion where it comes from, although I already worked on opencart. The next day was spent to understand 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 contact.php controller of 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 transfer values ​​from the form to the body of the letter, then add to the controller

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

I only just deal with Opencart 3 and do not really like to put incomprehensible additions, but I like to disassemble and study everything, and after the client launched the site and on the same day after the first order, it was decided to rework the letter that comes to the administrator and manager about the order, namely, what would be in the letter:

  • surname
  • telephone
  • address
  • town
  • 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:

while the administrator receives such a sad letter (((


Well, as you understand, or rather, whoever kept their online stores at least once, will immediately say that this is no good, do not call or find out any information and to get more detailed information you need to go to the admin panel, and if you are on the road and can't go to the admin area?

Well, in the end, I went the other way and made a simple substitution of letters, i.e. the admin will receive the same letter as the client)

and now a little magic and trick)

Opencart 3 letter to admin about order

In order for an opencart letter to the administrator about the order to receive 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

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

$ 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 ();

Insert this code below it:

$ 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 code insert was inserted into the section where the letter is formed and sent to the buyer, and we also send the same letter to the administrator as you can see we have substituted the letter template order_alert )))

order_alert.twig

What we did above in fact will not change anything, we will receive the same wretched letter, and all because we have not yet changed the template of the letter that should come to the administrator!

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

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

After that, we will receive such a letter in the mail)


Well, as usual video))

There are no related posts.

On October 28, 2019, new versions of the module for sending notifications from OpenCart / ocStore were published, in which the bug with the incorrect operation of the sender name selector was fixed if the client / partner uses more than 1 sender name. If you are using an older version of the module, we recommend that you reinstall 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 the engine files, or due to the use of modules that use modifiers. In this case, contact our support and you will be helped to install the module for sending SMS / Email notifications.

With the help of the mailing list integration module "site: SMS / Email mailings and notifications" and OpenCart / ocStore, you can send SMS and Email notifications on specified events to the administrator and buyers 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 the administrators (one or several) of the online store about the appearance of a new order (Email sending is only supported for version 3.0)
  2. Automatic sending of SMS / Email messages to users of the online store when order status changes
  3. The ability to configure any mode of 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 templates (for example, notification of a new order, change of order status, and much more), including standard and personalized
  7. Flexible customization of notifications: You can customize SMS / Email notifications only for certain order statuses
  8. Personalization of SMS / Email texts (including subject line)
  9. Online account balance
  10. Saving the history of sent SMS / Email messages
  11. Ability to send Email through our SMTP server
  12. Filtration of incorrect phone numbers (long, short);
  13. Recognition of phone numbers in various formats, for example, +79001234567, 79001234567, 89001234567, etc.;
  14. Ignoring non-mobile phone numbers;
  15. Automatic download of the used sender names from your personal account of SMS mailings sms website;
  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.Setup


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

As you know, OpenCart / ocStore 3.0 lacks the ability to install files to the system folder (which we need), so:

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





  2. After that go to "Modifiers" and click the "Update" button

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











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


8.Creating templates for SMS messages about the status of orders for buyers of an online store

  1. Open the tab "SMS templates to the buyer"
  2. Enter the texts of the SMS templates of the activated statuses using the personalization parameters, if necessary

9.Creating a new order email template for online store administrators


10.Creating email templates for 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 subjects and enter the texts of the templates of the Email-messages of the activated statuses using the personalization parameters, if necessary
  4. Click the "Save" button at the top right

11.Support templates

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

12.Personification of SMS / Email texts

The following personification variables are available in the message text:

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

13.Sending an arbitrary 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 an arbitrary 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 - 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 your personal account of SMS mailings sms ..

17. Replenishment of the balance of SMS-mailings

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

18 common problems and difficulties

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

Test messages for free