blog-page-header-bg

Development and Configuration of Order Email Coupons in Magento 2

COMMENTS (0)
Tweet

 

 

E-commerce businesses always needs dynamic rules of marketing to attract and lure their customers. The more the customers visits the sites, the more opportunity for the merchants to sell their products and ultimately, in returns a handsome revenue.

Magento-2 a leading E-commerce platform provides a full flexible and customizable architecture to implement any sort of automation that ultimately leads in generating customer traffic and business.

The automated coupons in order email is one of the marketing tactics of many e commerce businesses and in this blog we will cover the implementation of “order email coupons” within Magento-2 system.

The module “order email coupons” will email new coupon in every order email, to lure customer to re-visit site and shop more.

We will try to cover each and every necessary step of module development and configurations.

For reference, we have attached screen-shots for letting it know, how module need to be configured.

SCREENSHOTS:

Order Email Coupons - Magento 2 Blog folio3

Order Email Coupons - Magento 2 Blog folio3

Order Email Coupons - Magento 2 Blog folio3

Order Email Coupons - Magento 2 Blog folio3

Order Email Coupons - Magento 2 Blog folio3

Order Email Coupons - Magento 2 Blog folio3

 

MODULE STRUCTURE & IMPLEMENTATION

Step-1:

Create new module, at following path:

app/code/Folio3/OrderEmailCoupon

Step-2:

Create required module files and folder:

app/code/Folio3/OrderEmailCoupon/registration.php

 

app/code/Folio3/OrderEmailCoupon/etc/module.xml

 

Step-3:

We will provide new order email templates for logged-in and guest customers. Add templates code in file:

app/code/Folio3/OrderEmailCoupon/etc/email_templates.xml

 

Step-4:

In order to show the added emailed templates under admin→stores→configuration…

We need to code the following module file:

app/code/Folio3/OrderEmailCoupon/etc/adminhtml/system.xml

 

Step-5:

Create email templates (html) files:

For Guest Customer(s):

app/code/Folio3/OrderEmailCoupon/view/frontend/email/order_new_guest_with_coupon.html

For Logged-in Customer(s):

app/code/Folio3/OrderEmailCoupon/view/frontend/email/order_new_with_coupon.html

Please insert, the required gift coupon code in each email templates

 

Step-6:

Create need shopping cart rule under admin→marketing→promotions→cart price rules, with following necessary configurations, also highlighted in screen-shots:

Active: Yes

Coupon: Specific Coupon

(Checked) Use Auto Generation

User per Customer: 1

Note:

This rule will be utilized for creating dynamic coupon. The logic will be covered shortly.

Once rule is configured, please save it, copy the rule ID from URL and paste under text field at admin→stores→configuration→folio3→gift coupon→generate rule ID…

 

Step-7 (final step):

We have almost completed the required module files & folders with configurations.

In this step, we will add event “email_order_set_template_vars_before” at following path, that will be responsible for inserting coupon information at the time of sending order email.

app/code/Folio3/OrderEmailCoupon/etc/events.xml

 

Create observer file:

The observer will check for “Rule ID” and if found, generates dynamic coupon and bind it in order emails.

app/code/Folio3/OrderEmailCoupon/Observer/OrderEmailCoupon.php

Please feel free to comment or reach out if you have any questions. If you need any help with customizing your Magento 2 web store, please get in touch with us.

CALL

USA408 365 4638

VISIT

1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Latest From Our Blog

Development and Configuration of Order Email Co...

January 9, 2019
    E-commerce businesses always needs dynamic rules of marketing to attract and lure their customers. The more the customers visits the ...
Read more

The Development Steps for Conventional Admin Fo...

December 17, 2018
    The learning curve for Magento 2, with all of the updates, has become even steeper. In this blog, I plan to showcase you how to devel...
Read more

Magento Update Order Data Using Observer

December 3, 2018
    Sometimes we may need to update/change order information like custom_field after an order is placed. We can easily do this on the fly...
Read more