Auto Generation of Coupon Codes in Magento 2
In order to auto-generate a coupon code, first add new cart price rule.
To add a new price rule, navigate to Marketing => Cart Price Rules.
Press “Add New Rule”. Select the conditions and actions for the rule. And if you want to auto-generate a coupon, in the section Rule Information, set the following:
Coupon: Specific Coupon.
In Coupon Code put a tick in “Use Auto Generation” box.
But how will your coupon look like and how will it work?
Navigate to Stores => Configuration.
Under Customers section, select Promotion.
Here you can define the following:
- Code Length – defines the number of symbols in your code.
- Code Format – defines the format of your code. It can be Alphanumeric, Alpabetical, Numeric.
- Code Prefix – it’s a code that is added before all coupon codes. This code is not included in the number of symbols in a code. If you don’t want any prefix, leave the field blank.
- Code Suffix – it’s a code that is added after all coupon codes. This code is also not included in the number of symbols in a code. If you leave it blank, there will be no suffix in your coupon codes.
- Dash Every X Characters – if you want your coupon code to look like this: abc – def – ghi, then select “3” here. A dash will be added after every 3 caracters.
How to generate a coupon code?
Create a new one and set “Use Auto Generation”.
Configure other settings in the price rule and press “Save”.
Open a Cart price rule that is already configured (Marketing => Cart Price Rules).
Navigate to “Manage Coupon Codes” section.
Here you have the same settings as we checked above. Plus there is a “Generate” button below these settings and “Coupon Qty” above it.
Enter the number of coupons that you want to generate. And press the “Generate” button.
Now after you scroll down, you will see the list of codes.
You can export them in a CSV file. Select the codes that you want to export and press the corresponding button.
Now you can give these codes to your clients so they could use the discount on checkout.
How can you track coupon usage?
Navigate to Reports => (Sales) => Coupons
Select for what period you want to check coupon usage.
Select Cart price Rule, Select Order status and press “Show Report”.
Now you will see how many times your promo codes have been used.