Documentation
Back to website >

Conditions framework

What are Conditions (Rules)?

Every ecommerce business needs to define its own business rules in order to control the content and functionality of its ecommerce web site. That is why we have developed a powerful conditions (rules) framework, which we have integrated in most of our plugins. With the conditions framework you can define your own conditions (rules) based on customers, categories, manufacturers, products and product specifications.  These conditions are evaluated when a customer visits a page in your store. For example when a customer visits a product page then all product conditions will be evaluated based on the current product. Once evaluated the conditions could have two possible values - True or False. If the condtiion is evaluated to True then the entity, this condition belongs to, will be visible on the current page otherwise it won't be visible.

Conditions Tab

Every plugin that supports Conditions has a Conditions tab in the administration. 
In the Conditions tab you can define the conditions belonging for the current entity i.e Slider, Html Widget etc.
When a user visits a page where a condition is evaluated to True, the entity to which this condition belongs will be visible on the page. 

  1. Condition Name - The name of the condition. Used to specify some meaningful name for the condition.
  2. Active - used if you want to activate/deactivate the condition without the need to delete any of the already defined condition groups.
Note: If a condition is not active then the entity this condition belongs to will not be visible in the public store.


Condition Groups

A condition consists of condition groups. Each condition group is evaluated separately and then the results of all the condition groupes are combined with an OR operator.

Note: If at least one of the condition groups is evaluated to True then the whole condition will be evaluated to True

To add a condition group you need to click on the Add Condition Group button.

Condition Group - Default State 

The Default State is a condition group that is aways present (you can't remove it).
It has ony two states - Fail or Pass, which are always evaluated to False or True, respectively.

Note: if you do not define any condition groups, the Default State group will determine whether the condition is evaluated to False or True. Or if the Default State is set to Pass then the whole condition will be evaluated to True regardless how many condition groups you have.

Condition Statements

Condition groups consist of condition statements. All condition statements within a group are evaluated separately and then the results of all the condition statements are combined with an AND operator. This means that if at least one condition statement is evaluated to False then the whole condition group will be evaluated to False.

To define a condition statement you need to select the followings:

Condition Type

Condition Property

Operator

Value

 

Condition Statement Types

Condition statement type reflects a real entity in nopCommerce i.e customer, category, product etc.

  • Customer - evaluates in the context of on the current customer that is visiting a page. 
  • Category - evaluates in the context of the current category when you are visiting on a category page. Automatically evaluates to False on any other pages. 
  • Manufacturer - evaluates in the context of the current manufacturer when you are visiting a manufacturer page. Automatically evaluates to False on any other pages.
  • Product - evaluates in the context of the current product when you are visiting a product page. Automatically evaluates to False on any other pages.
  • Product Specification - evaluates in the context of the current product when you are visiting a product page. Automatically evaluates to False on any other pages.

 

Adding Condition Statements

When you click on the Add new record button, in a Condition Group a popup will appear.

  1. From the Condition Type dropdown, you can choose the type of the condition statement.
  2. From the Condition Property dropdown, you can choose for what property this condition will be applied.
  3. From the Operator dropdown you can choose the operator that will be applied for the Type and Value.
  4. The Value is either in a dropdown or a numeric textbox - depending on the choice of Condition Property. In it you can select the value for your Condition Statement.

Conditions Tab - Condition Example

In the picture above, you can see an example of a Condition Group with two Condition Statements.
Assuming that the html widget is mapped to a widget zone on the product details page, this condition specifies that the html widget will be shown when the Manufacturer of the product is Equal To ASUS and the Customer is NOT logged in. If any of this Condition Statements is false the whole Condition Group is false and if the Default State is set to Fail the conditions are not met, and the html widget will not be shown for the current product.

Please note that the product condition statement is valid only if the html widget is mapped to a widget zone on the product details page. Otherwise the product condition statement will be evaluated to false as will any conditions statements with a Condition Type Product.

You can Edit or Delete a Condition Statement by clicking on the respective buttons.

Override Product Conditions

From the Override Product Conditions tab you can include or exclude products regardless of the conditions. For example if you add a product with the include state, the html widget will be shown for that product on its product details page, regardless of all conditions. If you add a product with the exclude state, the html widget will not be shown for that product on its product details page, regardless of all conditions.

You can add a product override by clicking on the Add a new product button.

Please note that the product overrides are valid only if the html widget is mapped to a widget zone on the product details page. Otherwise the product overrides will be disregarded.

Override Product Conditions - Creating a Product Override

To add a Product Override you need to select the product, by clicking on the checkbox next to it. You can also change the State of the product.

After you have selected your products, you need to click on the Save button.

You can filter your products by Product name, Category, Manufacturer, Store and Vendor.

After you have finished adding Product Overrides, click on the close button at the top right corner of the window and you will see the Product grid refreshed with the added product overrides.

Override Product Conditions - Editing a Product Override

In the picture above, you can see two product overrides. The Toshiba Satellite product have the Exclude state. This means, that the html widget will not be shown for this product.

The Acer Aspire product have the Include state. This means, that the html widget will be show for this product, regardless of the condition.

From the grid, shown in the picture above, you can edit or delete a Product Override.

Override Customer Conditions - Creating a Customer Override

From the Override Customer Conditions tab you can include or exclude customers, for which the html widget will show on the product pages regardless of all conditions. For example if you add a customer with the include state, the html widget will be shown on the product pages (assuming that the widget is added to a widget zone on the product page) for this customer, regardless of all conditions. If you add a customer with the exclude state, the html widget will not be shown on the product pages for this customer, regardless of all conditions.

You can add a customer override by clicking on the Add a new customer button and follow the steps in the image above.