My Cart 0

User Manual - Coupon Code Generator

Magento 2 Coupon Code Generator allows generating individual coupon codes depending on custom rules. Rules determine the priority, coupon usage, format, coupon conditions, actions, and other parameters and can be attributed to specific websites and customer groups. Moreover, coupons can be designed for individual emails and automatically sent to the recipients selected in a customer database. All generated coupons are tracked from a separate table. 

 

 

Installing Coupon Code Generator

Command Line Installation

  1. Backup your web directory and store database
  2. Download the Coupon Code Generator installation package
  3. Upload the contents of the Coupon Code Generator installation package to your store root directory
  4. In the SSH console of your server, navigate to your store root folder:
cd path_to_the_store_root_folder

run the following command: 

php bin/magento module:enable Aheadworks_Coupongenerator

then:

php bin/magento setup:upgrade

after:

php bin/magento setup:static-content:deploy -f

    5. Flush store cache; log out from the backend and log in again

Make sure the installation is done from under the FTP administrator account. Otherwise, set 775 permissions to the store root directory after the extension is deployed.

Composer Installation

  1. If you are installing an extension from Aheadworks for the first time, you need to add our composer repository to your Magento store:

Login to your ssh console and navigate to your store folder:

cd path_to_the_store_root_folder

Run the following command:

composer config repositories.aheadworks composer https://dist.aheadworks.com/

On successful execution of the command you will be able to use the composer to install the extensions.

To install the extension:

     2. Login to your ssh console and navigate to your store folder:

cd path_to_the_store_root_folder

 3. Run the following command to install the latest version of the extension:

composer require aheadworks/module-coupongenerator

if you need to install a specific version, run this command:

composer require aheadworks/module-coupongenerator:<version>

 

Specify the version of the extension in <version>

 

When prompted, enter Public Key (Username) and Private Key (Password):

Public Key (Username) and Private Key (Password) | Coupon Code Generator for Magento 2

Both Public Key (Username) and Private Key (Password) can be found in My Projects and Licenses in your personal account on our site:

4. Enable the extension:

php -f bin/magento module:enable <Module_Name>

 

Add the product name in <Module_Name>

Next, register the extension:

bin/magento setup:upgrade

Recompile your Magento store if you are in the Production mode:

bin/magento setup:di:compile

To verify that the extension is enabled, run this command:

bin/magento module:status

Clean store cache, by running the following command:

bin/magento cache:clean

Log out and Log in the backend again.

To upgrade the extension:

     5. To update or upgrade an extension:

Download the updated extension file. Take note of the module-name and version. Export the contents to your Magento root.

If a composer package exists for the extension, run one of the following.

Update per module name:

composer update aheadworks/module-coupongenerator

Updater per version:

composer require aheadworks/module-coupongenerator:<version>

Run the following commands to upgrade, deploy, and clean the cache.

php bin/magento setup:upgrade --keep-generated 
php bin/magento setup:static-content:deploy
php bin/magento cache:clean

 

 

Uninstalling Coupon Code Generator

Since Magento introduced declarative Database you need to be very carefull when uninstalling or disabling the module.

NOTE: Please be very careful when uninstalling/disabling this module. This module uses a declarative DB scheme. Once the module is uninstalled the DB tables will be lost.

Manual Removal

1. Disable the module by executing the following commands:

php bin/magento module:disable Aheadworks_Coupongenerator 
php bin/magento setup:upgrade

2. Remove the extension files from the following folder:

app/code/Aheadworks/Coupongenerator

Automatic Removal (via Composer)

1. Disable the module by executing the following commands:

php bin/magento module:uninstall Aheadworks_Coupongenerator

 

 

 

Extension compatibility

Module Version 

Magento Version 

1.2.9  and earlier versions

2.3.Х - 2.3.6

2.4.0 - 2.4.3

As of version 1.2.10

2.4.0 - 2.4.5

As of version 1.2.11

2.4.4 - 2.4.6

As of version 1.2.13

2.4.5 - 2.4.7

As of version 1.3.1

2.4.6 - 2.4.8

The PHP version depends on your current Magento version. Please, refer to your Magento version release notes.

 

 

Introducing Coupon Code Generator Extension

 

Extension Overview

The Coupon Code Generator Extension enhances the process behind managing and creating coupon codes. With the help of predefined email templates, variables and rules, the coupon codes can be generated and sent to a particular customer or customer group in a few clicks. Coupon code usage allows for sales campaign tracking and issued coupon code management.

 

Key Features

  • Generate Coupons - the main section where store administrator creates and send the coupon codes to the customers;

  • Manage Coupon Codes - the section where the coupon code related information can be found, also used for reporting purposes;

  • Manage Rules - the section where coupon code rules are created and managed.

 

Using Magento 2 Coupon Code Generator 

Extension Configuration 

 

The extension settings can be found under Stores > Configuration > Aheadworks extensions > Coupon Code Generator

Here store administrator has an access to the following settings:

  • Email Sender - defines the email from which the coupon code notifications will be send;

  • Email Template - defines the email template which will be sent to the customer (templates can be found and edited at the FTP of the store under view/frontend/email).

 

Managing Rules

When the extension is installed the first thing the administrator wants to do is to create the coupon code rules. The rules will further be used to quickly generate and send the coupon codes.

 

The coupon code rules can be created from Marketing > Coupon Code Generator by Aheadworks > Manage Rules

 

The Manage Rules section provides an overview of all the rules available:

  • Click on the Columns button to look through available columns and customize the grid, remove/add columns to match your workflow;

  • Click on the Filter button to look for the rules matching a custom set of attributes;

  • Click on the Default View button to save a number of custom grid views to switch between, depending on the current task.

 

These active elements of the grid are shared with the Manage Coupon Codes and Generate Coupon(s) for Customers sections that will be covered later in this readme.

 

Before generating coupons, administrators must establish rules at Marketing > Coupon Code Generator by Aheadworks > Manage Rules.

  • Rule Information - Includes standard Magento settings (General Configuration and Coupon Usage) plus a specialized Code Format block. Here, you can define coupon length, format, prefixes, suffixes, and dash separators.

  • Conditions - Sets the criteria that must be met for the coupon to apply.

  • Actions - Defines the discount type (fixed or percent), amount, and specific items the discount applies to.

Once done setting up the rule store administrator clicks the 'Save' button.

 

Generating Coupon Codes

To generate coupon code with the rule created administrator navigates to Marketing > Coupon Code Generator by Aheadworks > Generate Coupons.

 

This section offers two modes:

  • Generate Coupon for Email - Generate a single code to a specific recipient. Codes are tied to the provided email address.

  • Generate Coupon(s) for Customers - Select multiple customers from a grid and apply a rule to generate codes for the entire group simultaneously.

 

The coupon codes are tied to the email address and cannot be generated without specifying one.

 

Generating coupons from Customer Account

Administrators can issue coupons while managing a specific user at the backend via the Coupons block in the customer account area. Ticking the Send Email with Coupon checkbox ensures the notification is sent upon saving the account.

 

 

 

Manage Coupon Codes

 

The coupon codes have been generated and can now be tracked under Marketing > Coupon Code Generator by Aheadworks > Manage Coupon Codes

 

Managing Coupon Codes Grid

The grid at Marketing > Coupon Code Generator by Aheadworks > Manage Coupon Codes provides insights into campaign performance.

  • Time Used - View exactly how many times each customer (e.g., John Doe) has utilized their code.

  • Status Control - Deactivate or delete specific codes as needed.

 

 

Advanced Integration & Variables

 

Newsletter and General Notification Email Variables

 

The Coupon Code Generator extension allows for the automated delivery of coupon codes within newsletters and general notification emails. Once an email is sent, the system automatically transforms these variables into specific coupon values.

 

The Five Core Variables:

  • {{var subscriber.generateCoupon(ruleId, alias)}} – This is a service variable. It initiates the coupon generation based on the defined ruleId but does not actually display the code in the template.

  • {{var subscriber.getCouponCode(alias)}} – This variable adds the actual generated coupon code to the email.

  • {{var subscriber.getCouponExpirationDate(alias)}} – Use this to show when the discount expires.

  • {{var subscriber.getCouponDiscount(alias)}} – This displays the discount amount (e.g., 20% or $50) defined in the rule.

  • {{var subscriber.getUsesPerCoupon(alias)}} – This indicates how many times the specific code can be used.

Variable Parameters:

  • ruleId: The specific ID of the Coupon Code Generator rule used for values and conditions.

  • alias: A preferred name or "nickname" defined by the store owner to link the generation logic to the display variables.

 

Critical Usage Requirements:

  1. Placement Order: The service variable (generateCoupon) must be placed in the template BEFORE any other extension variables, as it starts the generation process.

  2. Customer Group Alignment: Customer groups must match in both the coupon rule conditions and the newsletter/follow-up email conditions. If a rule is for "Group A" but the email is sent to "Group B," the code will not generate, and the email will contain blanks.

Multiple Coupons in One Email 

To send multiple different discounts, assign a unique alias to each:

  • {{var subscriber.generateCoupon(1, WATCH20)}}

  • {{var subscriber.generateCoupon(2, BAG20)}}
    You can then call these specifically: "Use {{var subscriber.getCouponCode(WATCH20)}} for watches and {{var subscriber.getCouponCode(BAG20)}} for bags".

 

Coupon Code Generator Integration

Integration with Follow Up Email

The extension integrates seamlessly with Follow Up Email by Aheadworks. The logic remains identical to the newsletter variables, but the prefix changes to coupongenerator.

Follow Up Variables:

  • {{var coupongenerator.generateCoupon(ruleId, alias)}}

  • {{var coupongenerator.getCouponCode(alias)}}

  • {{var coupongenerator.getCouponExpirationDate(alias)}}

  • {{var coupongenerator.getCouponDiscount(alias)}}

  • {{var coupongenerator.getUsesPerCoupon(alias)}}

 

Integration with HelpDesk Ultimate

When the Coupon Code Generator extension is installed alongside Help Desk Ultimate by Aheadworks, it empowers help desk agents to provide immediate sales incentives during customer support interactions.

  • Direct Generation: Help desk agents can generate and send unique coupon codes directly from within a ticket thread in the Magento backend, streamlining the process of resolving customer issues with a discount.

  • Agent Workflow: The extension adds a specific section to the ticket thread administrator menu. To issue a coupon, the agent simply selects a predefined Coupon Code Generator rule from this menu before submitting their reply to the ticket.

  • Automatic Delivery: Once the agent replies, the coupon code is automatically generated based on the selected rule's conditions. The code is then appended to the bottom of the ticket response, clearly indicating the specific discount the customer has received.

 

Coupon Code Generator | Coupon Code Generator for Magento 2

Product Page

Write Your Own Review

Already used our product?

We would appreciate your feedback. Please, leave a review.

Only registered users can write reviews. Please Sign in or create an account
Report incorrect information

Still Have Questions?

Our customer care team is here for you!

Contact Us