How to configure condition types in Magento 2?

Conditions are used to create certain rules, subject to which the client will be given a discount. This tool helps to make promotions more personalized and increase your store's profits.

So how to configure a condition in Magento 2? Let’s consider an example. Say, you want to configure a discount if there are red items in the shopping cart. For this, do the following:

Step 1. Go to the Admin and configure the new price rule by navigating to Marketing > Promotions Cart Price Rules.

Step 2. Complete the Rule Information section and save the changes.

Step 3. Now expand the Conditions section:

conditions configuration

Step 4. Create a magento 2 cart price rule custom condition by pressing the + button. 

ALL\TRUE values of the condition are set by default. You can change these values to ANY\FALSE to exclude something from the condition.

Step 5. Choose a condition to add in the shown dropdown (Product attribute combination in our case).

Step 6. Define the criteria for the conditions by clicking the more (…) link to display the input field and selecting the required options (Color - Red in our case):

conditions overwatch

All options in bold can be changed. ALL can be changed to ANY, TRUE to FALSE, FOUND to NOT FOUND, is to is not\in undefined. If you want to remove some condition, press the × button.

That’s it. Condition is set. If you want to add more conditions, click Add (+ icon) and define another condition. Conditions can be defined as many times as you want to set the appropriate rule for the cart price. 

After that, you will have to define the action for this condition:

actions configuration

Don’t forget to save the configuration. 

The Custom Promo Conditions extension expands the capabilities of Magento's default Conditions. With it, you can add advanced conditions based on customers' preferences by checking customers' purchase history and account details.

This extension will provide the advanced criteria condition types in Magento 2, so you will be able to search for and choose between such conditions as:

  • Customer Attributes.

  • Purchases History.

  • Orders subselection.

What are the available Magento 2 condition types?

Magento 2 condition types that are available according to Magento documentation:
"eq" => equalValue
"neq" => notEqualValue
"like" => likeValue
"nlike" => notLikeValue
"is" => isValue
"in" => inValues
"nin" => notInValues
"notnull" => valueIsNotNull
"null" => valueIsNull
"moreq" => moreOrEqualValue
"gt" => greaterValue
"lt" => lessValue
"gteq" => greaterOrEqualValue
"lteq" => lessOrEqualValue
"finset" => valueInSet
"from" => fromValue,
"to" => toValue

What are the Magento 2 search criteria condition types for?

Magento 2 search criteria condition types are nothing more than "search criteria in Magento 2" for finding/filtering the needed result from the repository. Conditions are used to create rules. If these rules are followed, then a certain action will be taken.

→ Add downloadable content and enhance product information with the Product Attachments extension for Magento 2.

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.