How to Create Magento 2 Coupon Codes?

How to Create Magento 2 Coupon Codes?

Magento 2 allows store owners to create and manage customer coupon codes.

This guide will cover different methods of creating specific and bulk coupon codes. You can set up cart price rules and apply discounts to particular customer groups.

With these instructions, we aim to make this process easy for readers with varying levels of technical expertise.

Steps to Create Coupon Code in Magento 2

Creating Specific Coupon Codes

  1. Navigate to Marketing > Promotions > Cart Price Rules in the Magento 2 admin panel.
  2. Click the "Add New Rule" button to create a new cart price rule.

Magento 2 Cart Price Rules Navigation

  1. In the "Rule Information" tab, set "Coupon" to "Specific Coupon" and enter a custom coupon code.
  2. Configure the rest of the rule settings, such as customer groups, usage limits, and active dates.
  3. Save the rule to activate the coupon code.

Creating Bulk Coupon Codes

  1. Follow steps 1-3 from the "Creating Specific Coupon Codes" section.

Magento 2 Specific Coupon Code Rule Information

  1. In the "Rule Information" tab, check the "Use Auto Generation" checkbox.

Magento 2 Use Auto Generation for Bulk Coupon Codes

  1. Save the rule.
  2. Go to the "Manage Coupon Codes" tab within the cart price rule.
  3. Configure coupon code generation settings, such as coupons qty, length, format, prefix, and suffix.

Magento 2 Managing Bulk Coupon Codes

  1. Click the "Generate" button to create the bulk coupon codes.

Setting Up Cart Price Rules

  1. Navigate to Marketing > Promotions > Cart Price Rules.

Magento 2 Setting Up Cart Price Rules

  1. Create a new rule or edit an existing one.
  2. Configure the rule's general information, conditions, and actions.
  3. Save the rule to activate the cart price rule.

Applying Discounts to Customer Groups

  1. Within the cart price rule's "Rule Information" tab, locate the "Customer Groups" setting.

Magento 2 Applying Discounts to Specific Customer Groups

  1. Select the desired customer groups to apply the discount.
  2. Save the rule to apply the discount to the selected customer groups.

Frequently Asked Questions

1. How do I get a promo code for Magento?

To get a promo code for your Magento 2 store, follow the steps outlined in this guide. Use the steps for creating specific coupon codes or bulk coupon codes.

Once you've set up cart price rules and generated the coupon codes, you can share them with your customers. It can be through emails, newsletters, or other marketing channels.

2. How to get a discount for ordering Magento 2?

Customers should enter the number associated with the coupon code during the checkout process. Once the code is applied, the discount will be reflected in the order total.

Magento 2 also supports the QR code format, which customers can scan using their smartphones. They can access more information about the promotion and apply the discount.

3. How to generate coupon codes in Magento 2 programmatically?

To generate a coupon code programmatically in Magento 2, you can use the Magento 2 API. Ot you can write custom code to interact with the cart price rule and coupon code management system.

You can create advanced coupon code generation logic by using Magento 2's built-in functions and classes.

When creating coupon codes, it's essential to consider the code prefix, code length, and code suffix. It can help distinguish the codes and make them more memorable.

Additionally, setting the dash for every X character can improve code readability. It makes it easier for customers to enter the code during checkout. For example, if you set the dash to every three characters, your code could look like "ABC-123-XYZ."

Using the generate button in the "Manage Coupon Codes" tab allows you to create multiple coupon codes at once. It is useful when you want to offer a number of coupons to various customer groups.

Select the "Use Auto Generation" checkbox when creating bulk coupon codes. It enables the automatic generation of multiple codes based on your settings.

To ensure that your cart price rules and coupon codes function correctly, it's crucial to click save after adding the settings. It activates the coupon codes and allows customers to use them in your Magento 2 store.

With these steps to marketing promotions and cart price rules, you can effectively manage coupon code generation. You can provide attractive discounts to your customers, driving sales and customer loyalty.


This guide provides an overview of generating coupon codes in Magento 2. We covered specific and bulk coupons, cart price rules, and applying discounts to customer groups.

Following the step-by-step instructions, you can easily create and manage coupon codes for your online store. For more practical and helpful guides, check out Magento tutorials.

Nikita S.
Nikita S.
Technical Writer

As a professional content writer, Nikita S. is experienced in crafting well-researched articles that simplify complex information and promote technical communication. She is enthusiastic about cloud computing and holds a specialization in digital marketing.

Get the fastest Magento Hosting! Get Started