Magento 2 Cart Price Rules allow store owners to run quick discounts or seasonal promotions to specifics products in the store.

Store owners can create a discount in the backend based on a set of conditions, allowing shoppers to apply these discounts to items in the shopping cart.

The discount to the items can be applied to the shopping cart manually when the shopper enters a valid coupon code in the discount field. Or, automatically anytime the cart price rule conditions are met.

When the discount is applied in the shopping cart, the discount amount appears in the summary area, under the subtotal.

Follow the steps below to create a cart price rule in Magento 2:

Step 1: Add a New Rule

log in to the admin panel, and go to Marketing > Promotions > Cart Price Rules.

All existing cart rules appear in the grid. To search a rule, use the filter options at the top of each column, enter the rule to search, and click the "Search" button

From the grid, you can search a rule by ID, Rule, Coupon Code, Priority, Status, Web Site, Action, Start, End.

  • ID: filter by a specific rule ID number.
  • Rule: filter by rule name defined when the rule was created
  • Coupon Code: filter by code name defined when the rule was created.
  • Priority: filter by the priority defined for a rule.
  • Status: filter by rule status, Active or Inactive.
  • Web Site: Filter by websites defined for a rule.
  • Start: filter by the start date of the rule as defined when the rule was created.
  • End: filter by the end date of the rule as defined when the rule was created.
  • Action: Click Edit to display the Rule Information page and update the rule’s settings (for Commerce/Cloud only).
  • to clear all filter options in the grid, click "Reset Filter"
  • to update the rule, click in the role row (for Open Source) or in Edit link (for Commerce/Cloud only), update each area of the rule, then click save

To create a new promo rule, click "Add New Rule" into the upper-right corner

Magento 2 Cart price rule grid

Step 2: Rule Information Settings

Rule Name – enter the name of the cart price rule 

Description – enter a brief description of the rule

Active - If Yes, is selected the rule will go into effect immediately. Set to No, to disable the rule in the storefront.

Websites - select the websites where the promo rule is to be available

Customer Groups - select the customer groups to which the promo rule applies. If you want to restrict the promo rule to guests users, select "NOT LOGGED IN".

Rule info

In the "Coupon" field, you can choose to associate the promo with or without a coupon code.

If "No Coupon" is selected the promo rule will be applied in the shopping cart without the use of a discount code. The promo will auto apply in the cart if the conditions are met.

Rule info no coupon

If "Specific Coupon" is selected, the promo rule will be applied in the shopping cart with the use of a discount code:

  • In the "Coupon Code" field, enter a coupon code that the shopper must enter in the shopping cart to receive a discount.
  • In the 'Uses per Coupon" field, enter the number of times the coupon can be used.
    If "Use Auto Generation" is selected and that you save the rule, you will be able to generate multiple coupon codes (In "Step 6: Generate a batch of coupons") that can be used with the promotion.

Rule info specific coupon

Uses per Customer - enter the number of times the coupon code can be used by the same customer who belongs to any of the selected customer groups

From - enter the date the promo will start to take effect

To - enter the date the promo will end.

Priority - enter the priority of the promo rule in relation to other promo rules which are active at the same time. Useful when you have several promos that are active for the same product at the same time.

Public In RSS Feed - if selected, the promo rule will be published in RSS feeds

Rule info other settings

Step 3: Conditions Settings

In the Conditions that, you can describe the conditions that must be met for the promotion.

The promo rule will apply in the shopping cart if the conditions described here are met.

Follows the steps below to create a condition:

a) Click in the "Conditions". The first condition "If ALL of these conditions are TRUE:" appears by default.
This default condition applies the rule to all products.

To create different conditions by changing the combination of these values, you can click on "ALL" and select ALL/ANY. Or click on "TRUE" and select TRUE/FALSE

Rule condition

b) To add a new condition, click on the "Add" icon, at the next line and select from "cart attribute", "product subselection" or "combination"

Rule condition step


to create a condition based on "product subselection", choose "Products Subselection", and complete as follow in the condition statement:

  • click "total quantity" and choose "total quantity" or "total amount".
  • click "is" and select "greater than", then click the “more” (…) link, and enter 100.
    The condition is added and will take effect in the cart if the total quantity of the cart is 101 or greater

Rule condition step

To make this condition based on "Category"

  • Click on "Add" icon, at the next line
  • in the "Product Attribute" list, select "Category"

Rule condition step

  • click the more (…) link to display the input field
  • open the "Chooser" icon to display the category tree.
  • choose the checkbox of the category that you want to use as a condition for the price rule
  • Click the green "check" icon to accept the category selection(s)

Rule condition step

The condition can be based on any category that is a subcategory or child of the store’s root category.

To add more conditions, click Add icon in the next line, and define another condition.

To add a new product attribute to the cart price rules:

  • Go to Stores > Attributes > Product
  • in the product attribute grid, click on the attribute to open
  • In the left tab, select Storefront Properties.
  • Set "Use for Promo Rule Conditions" to Yes.
  • Click Save Attribute.
  • Go to Marketing > Cart Price Rules
  • From the cart price rules grid, choose the rule to open
  • Expand the Condition tab and select Product attribute combination.
  • Set this condition to one of the following values: FOUND (choose FOUND or NOT FOUND.), ALL( and select ALL or ANY)
  • Click the Add icon, the product attribute appears in the list of "Product Attribute"
  • To use the product attribute: choose the product attribute and click Save.

Step 4: Actions Settings

In settings, the step describes how the prices are updated in the shopping cart when conditions is met.

In the "Apply" field, you can choose from "Percent of product price discount", "Fixed amount discount", "Fixed amount discount for the whole cart", "Buy X get Y free"

  • If "Percent of product price discount Discounts" is selected, the discount item will be applied to the cart by subtracting a percentage from the original price.
  • If "Fixed amount discount" is selected, the Discounts item will be applied to the cart by subtracting a fixed amount from the original price.
  • If "Fixed amount discount for the whole cart" is selected, the Discounts will be applied to the cart by subtracting a fixed amount from the cart total.
  • If "Buy X get Y free" is selected, the discount will be applied in the cart based on the quantity that the shopper must purchase.

Discount Amount - enter the discount amount. This discount amount indicates a percentage, a fixed amount, or a number of items depending on the option selected in the "Apply" field.

Maximum Qty Discount is Applied To - enter the maximum quantity of the same product that can qualify for the discount in the same purchase.

Discount Qty Step (Buy X) - enter the quantity that the shopper must purchase to receive the discount.

Apply to Shipping Amount - If set to Yes, the discount amount apply separately to the subtotal and shipping amounts. If "No", the discount amount will apply only to the subtotal.

Discard subsequent rules - If set to "Yes", any other pricing rules that may apply to a product won't apply. if "No", multiple pricing rules will apply to the same product.

In the "Apply the rule only to cart items matching the following conditions (leave blank for all items)." tab, you can define as many additional conditions as needed for the action.

Free Shipping

  • If "No" is selected, the Free shipping is not available
  • if "For matching items only" is selected, the Free shipping is available only for items that match the conditions of the rule
  • If "For shipment with matching items" is selected, Free shipping is available for any shipment that includes matching item(s)

In the "Add Rewards Points" (for Commerce/Cloud only), enter the number of points the shopper will earn whenever the cart price rule is applied. Leave this field blank, when the reward points are not enabled.

When you complete with the "Action" settings, click "Save and Continue Edit"

Rule actions

Step 5: Labels Settings

In the "Default Rule Label for All Store Views" field, the text that you want to be used as the Default Rule Label for All Store Views.

If your store has multiple views, enter the appropriate label text for each store view. You can enter a default label for all store views, or enter a different label for each view.

Rule labels

On the shopping cart page, the label appears in the totals section, enclosed in parentheses to identify the discount.

Step 6: Manage Coupon Codes Settings

In this section, you can generate a batch of coupon codes to apply to the rule.

The batch coupons generation is an asynchronous operation, which runs in the background so that you can keep working in the backend without waiting for the operation to complete.

To enable the "Batch coupon generation settings",

  • go to "Step 2: Rule Information Settings"
  • set "Coupon" field to Specific Coupon, and select "Use Auto Generation"

Configure the "Batch coupon generation settings" as follow:

  • Coupon Qty: enter the number of coupons to generate.
  • Code Length: enter the code length excluding prefix, suffix, and separators.
  • Code Format: select one of the following: Alphanumeric, Alphabetical, or Numeric
  • Code Prefix (Optional): enter a prefix to be added to the beginning of the code. This field is optional
  • Code Suffix (Optional): enter a suffix to be added to the end of the code
  • Dash Every X Characters (Optional): - enter the number of characters between each dash. Dashes make codes easier to read and enter.Eg. if the code is 16 characters long, and there is a dash every 5 characters, it will look like xxxxx-xxxxx-xxxx-xxxxx
  • Click Generate.

The list of generated codes appears below in the grid:

Rule generate batch codes

Step 7: Add Related Dynamic Blocks (optional: for Commerce/Cloud only)

The Dynamic Blocks are blocks that are associated with the rule that display in the storefront whenever the conditions are met.

To add a Dynamic Blocks to the rule, from the grid, select the checkbox in the first column to select the blocks to associate with the rule.

Rule dynamic blocks

Once you have configured each section of the rule, click "Save" to save the rule

Step 8: Test The Rule In The Storefront

In the frontend, for any new rule added, Magento 2 recalculates the prices and the priorities accordingly.

When you add "a product that is included in the promotion" to the cart:

  • if the promo rule is based on "No Coupon" code, the discount will auto-apply for the product at the cart page if all conditions are met
  • if the promo rule is based on "Specific Coupon", code, the promo rule will be applied in the shopping cart when the discount code is used

The discount applied appears in the summary section on the shopping cart page.

Example of specific discount code "H20" applied in the cart page

Rule frontend view


We hope you find this step-by-step guide to create a cart price rule in Magento 2 helpful. Feel free to share this article or leave a comment below. Your opinion is much appreciated!

Tags: promo banners cart-price-rule