was successfully added to your cart.

How to Create Coupon Code in Magento 2

create coupon code - cart price rules in magento 2

Coupon Codes help buyers at your store to avail discounted prices. You can create single or bulk Coupon Codes in Magento 2 for a particular customer/product, group, or anyone depending on the purpose, need, or campaign.

First, you need to create cart price rule to apply discounts in the shopping cart based on a set of conditions.The discount can be applied as soon as the conditions are met or when a customer enters a valid coupon code. When applied the discounted price appears below the subtotal.


Step 1: Adding new rule

    • On the admin page, select Marketing. Then under promotions select Cart Price Rules
    • Click on the Add New Rule button on the top right cornerAdd-new-rule-1024x465
    • Under Rule InformationRule-name-1024x218
    • Rule Name- Enter the rule name as a reference
    • Description- Description of the ruleactive
    • Active – If you want the rule to go into effect then select yes
    • Websites – Select the website on which you would apply the rule
    • Customer Groups – It relates to which customer groups you want the coupon to applyCoupon
  • Coupon – If you want to associate the coupon to the rule, set the coupon to Specific Coupon. For this, you need to enter the coupon code that customer must enter to avail this coupon. You can limit the number of times the coupon can be used –
      • Uses per coupon- It tells the number of times the coupon can be used; if left blank then it won’t have any limit
      • Uses per customer- How many times the coupon code can be used by the same registered customer who belongs to any of the selected customer groups. This setting doesn’t apply to NOT LOGGED IN members. If there’s no limit then leave it blankPromotions


  • From/To- Starting and ending period for which the coupon will be active
  • Priority- It’s a number, referring to the priority of this price rule in relation to the Action settings of other price rules that might be active at the same time.( 1 has the highest priority)
  • Public in RSS Feed- To apply the rule to published listings select ‘Yes’

Step 2: Conditions


  • This setting is for specifying the conditions upon which the rule will be applied. It allows you to create different conditionsconditions_1
  • You can select ALL and TRUE link if you want to consider all the conditions while applying the codeConditions
  • Click on the ‘+’ button and choose the conditions to add. Choose Total Items Quantity, then if you want a condition such that total items quantity should be greater than 10, then click on ‘is’ link and select greater than option. To specify the value click on ‘…’ link and enter the value 10

So now Actions specifies how prices should be updated when conditions are met.

Step 3: Actions


  • Apply – It specifies the discount method –
    • Percent of product price discount- Price is discounted by subtracting this percent from the original price. So if you apply 10 then discounted price will be 10% less than the original price
    • Fixed amount discount- Price is discounted by subtracting this amount from the original price. So if you apply 10 then discounted price will be $10 less than the original price
    • Fixed amount discount for whole cart- Discounts the entire cart by subtracting a percentage from the cart total. So enter 10 in Discount Amount to subtract 10% from the cart total
    • Buy X get Y free- Defines a quantity that customer must purchase to receive a quantity for free. For this option, you need to specify the quantity in the Discount Qty Step(buy X) field that customer must purchase to receive the discount
  • Discount Number- Specify number without symbol depending upon the discount option selected
  • Maximum Qty Discount is applied to- Enter the maximum quantity of the same product that can qualify for the discount
  • Apply to Shipping Amount-
    • Yes- Applies the discount to subtotal and shipping cost
    • No- Applies to subtotal only
  • Discard subsequent rules- If set to ‘Yes’, it will prevent customers from receiving multiple discounts for the same product
  • Free Shipping-
    • No- Free shipping is not available
    • For matching items only- Free shipping only for items that match the conditions of the rule
    • For shipment with matching items- Free shipping for Matching items for which free shipping is available

Step 4: Labels


Labels appear in the order below the subtotal.

  • Enter the text that you want to be used as the Default Rule Label for All Store Views
  • If you have multiple views, or multiple websites with multiple views enter the appropriate text for the label

Now if you save this rule and scroll down to Manage Coupon Codes section.


  • Coupon Qty- Number of coupons that you want to generate
  • Code Length- Enter the coupon code length excluding prefix, suffix or separators
  • Code Format-
    • Alphanumeric
    • Numeric
    • Alphabetic
  • Code Suffix- This will be added to the beginning of the coupon code
  • Code Prefix- This will be added to the end of the coupon code
  • Dash every X characters- Enter number of characters after which dash should be placed. So if there are 9 characters and if you specify 3 in this option then it would be xxx-xxx-xxx

Click on Generate the list of configured coupon codes appears.


That’s how you create coupon codes in Magento 2.

If you like our How-to Tutorials series, please subscribe to our newsletter and get the tutorials straight to your email!