🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Create Coupon Code in Magento 2? – Complete Guide

By Shivbhadrasinh GohilUpdated on Jun 16, 2025 7 min read

Offering discount codes is a proven technique to convert more visitors into customers. In Magento 2, you can create coupon codes in a few easy steps and get your campaigns running.

In this guide, you’ll learn how to create coupon code in Magento 2 and examples.

How to Create a Coupon Code in Magento 2?

Magento 2 has a concept of “Cart price rules” that define the rules (conditions) for discounts. In the cart price rule, you can create a specific coupon code required to avail the discount. You can also auto-generate coupon codes in Magento 2 for the cart price rule.

Method 1: Create a Specific Coupon Code

To create a Magento 2 discount code, navigate to Marketing > Promotions > Cart Price Rules in your admin.

Magento 2 admin with selected Cart Price Rules in Marketing section

In the Cart Price Rules grid, click the “Add New Rule” button.

Cart Price Rules grid

Enter a name and description for the cart price rule and select the applicable websites and customer groups.

To specify a coupon code for the discount, set Coupon to “Specific Coupon” and define your coupon code.

Magento 2 configuration for New Cart Price Rule

Optionally, you can also specify certain conditions and rules for the discount from the Conditions section.

You can set limits on the number of uses per coupon code or customer. And also define a specific date range for the validity of the coupon code.

It’s helpful to set a Magento 2 coupon expiration date for time-sensitive discounts.

Magento 2 coupon expiration date selection

Next, expand the Actions section to define the discount. In this example, we’re setting a 75% discount on the cart. You can also set a fixed amount or buy X get Y discount.

Actions section in the cart price rule

Click the “Save” button to save the cart price rule with discount code.

That’s how straightforward it is to create a specific discount code in Magento 2.

Method 2: Auto-generate Coupon Codes in Bulk

In Magento 2 cart price rules, you can use the auto-generation feature to create coupon codes in bulk.

To do that, check the “Use Auto Generation” option against the Coupon Code field.

Coupon Code field configuration

Now, configure the Conditions and Actions for the discount rule as per your needs and click “Save and Continue Edit” on the top right to save the rule. (This is important since you will not be able to generate the coupon codes without saving the rule)

Coupon codes rule saving

Scroll down to the Manage Coupon Codes section and configure the coupon code settings. Enter the quantity and length of the coupon codes you want to generate and select the format.

Click the “Generate” button.

Manage Coupon Codes section

Once generated, you can find the list of coupon codes in a grid under the same section.

list of coupon codes in a grid

That’s how you can have Magento 2 auto-generated coupon codes. You can start distributing these discount codes to your customers and promote the sales.

You can test the created Magento 2 coupon code on the shopping cart page in the front end.

shopping cart page in the front end

Ta-da! You’ve successfully created and applied a discount code in your Magento 2 store.

Examples of Magento 2 Coupon Codes

Magento 2 discount codes are helpful for promoting sales, and they’re more effective when used strategically. Here are some popular examples of how to create and use Magento 2 discount codes more effectively.

Product-specific Coupon Code

In Magento 2 cart price rules, you can set up conditions to offer discounts only on certain products. This can be useful while running seasonal sales.

Let’s say you want to create a discount code for a specific product in your Magento 2 store. You can do this by matching its SKU in the conditions section. Create a new cart price rule with the coupon code for the discount offer and add the conditions to match the product by its SKU, as shown below.

Set rule by applying condition for Product-specific Coupon Code

You can define multiple rules and logic in the conditions section to create Magento 2 discount codes using product attributes like SKU, category, brand, etc.

Customer Group-specific Coupon Code

You can change the scope of the cart price rules to create discount codes for specific customers in Magento 2. To do that, you’ll need a customer group to which you want to offer the discount.

Simply follow the above steps to create a discount code in Magento 2 using the cart price rules and select the customer group to which you want to offer it.

Select customer group to apply Coupon code


This way, you can create exclusive discount codes for your loyal customers in Magento 2.

Magento 2 Coupon Code Link

Convert coupon codes to link that apply discount directly at checkout.

Get Extension

Take the customer experience of your store to the next level (literally) with coupon code links. Our Magento 2 Coupon Code Link extension converts your normal coupon codes into links that customers can use to grab deals.

Using the extension, you can:

  • Convert existing coupon codes into links
  • Redirect links to specific pages in your store
  • Auto-apply discount code on the cart page

Make it easier for the customers to grab deals and discounts in your store. Create links for discount codes and share anywhere.

Shivbhadrasinh Gohil Full Image
Article byShivbhadrasinh Gohil

Shivbhadrasinh is the Co-founder & Chief Marketing Officer at Meetanshi. He leads the marketing team and is the person behind the marketing & branding success of the company. Being a seasoned digital marketer, he has been consulting online businesses for growth since 2010 and has helped 100+ clients with digital marketing success. He loves sharing tips and insights about the latest digital marketing trends aimed at helping online business owners.