ThemeHigh
  • Plugins
  • Documentation
  • Support
  • Partners
  • Login
  • Getting Started
    • Overview...
    • Add/Edit Custom Sections
    • Add/Edit Custom Fields
    • Add Display Styles
    • Set Tooltip Details
    • Price Fields & Types
    • Set Display Rules for Fields & Sections
    • How to Export/Import Fields & Sections Individually
  • Advanced Settings
    • Add Price Table
    • How to modify add to cart button text?
    • Add a Custom Validation Rule
    • Add a Confirm Field Validator
    • Choose a Layout Style
    • WPML Compatibility
    • Disable "Enhanced Select(Select 2)" for select fields
    • How to post extra options as URL Parameters?
    • Use the Div tag for displaying fields
    • Backup & Import Settings
  • FAQ
    • Frequently Asked Questions...
  • Compatible Plugin & Themes
    • Plugins & Themes...
  • For Developers
    • Hooks & References...

Documentation/Extra Product Option for WooCommerce/How to Set Conditional Rules for WooCommerce Product Fields?

How to Set Conditional Rules for WooCommerce Product Fields?

Last updated on December 14, 2022

 


General instructions to set display rules

To set display rules for product fields:

  1. Navigate to the WooCommerce → Extra Product Options → Product Fields page.
  2. Open the field property popup.Display_rules-fields.png– Click on the Add Field button to open the popup form if you are setting display rules for a new field.- Click on the Edit Field icon to open the popup form if you are setting display rules for an existing field.
  3. Navigate to the Display Rules tab from the popup.
  4. From this tab, you can define display rules. Here you can see two sets of rules, where the first one will be validated before loading the product page. The other one will be only validated once the page is loaded. You can add multiple conditions to each rule.
  5. Click on the AND or OR operator button to add multiple conditions and use these operators properly based on your requirement.
  6. Once the required conditions are added, save the changes made.

To set display rules for sections:

  1. Navigate to the WooCommerce → Extra Product Options → Edit/New Section.
  2. Open the section property form popup.Disply_rules-Sections.png
  3. Click on the Add New Section button to open the popup form if you are setting display rules for a new section.
  4. Click on the Edit Section button to open the popup form if you are setting display rules for an existing section.
  5. Navigate to the Display Rules popup and define the rules based on your needs as configured for extra fields.
  6. When the changes are done, save the changes made.

Conditions based on user role

Show or hide fields & sections based on user role. Below is the list of conditions available to display fields & sections based on the user role.

  1. Equal to / In
  2. Not Equal to / Not In

Example #1: Show field XYZ only for “Shop manager”.

User_role-display_fields.png

Example #2: Hide field XYZ if the user is a “Shop Manager” or an “Administrator”.

User_role_2.png


Conditions based on products

Show or hide fields & sections based on products. Below is the list of conditions available to display fields & sections based on the product.

  1. Equal to / In
  2. Not Equal to / Not In

Example #1: Show field XYZ if the product is Cap.

Products_display_rules.png


Conditions based on product categories

Show or hide fields & sections based on product categories. Below is the list of conditions available to display fields & sections based on the categories of the product.

  1. Equal to / In
  2. Not Equal to / Not In

Example #1: Show field XYZ if the product’s category is Hoodies.

Categories-display.png


Conditions based on product tags

Show or hide fields & sections based on product tags. Below is the list of conditions available to display fields & sections based on the product tags.

  1. Equal to / In
  2. Not Equal to / Not In

Example #1: Show field XYZ if the product tag is SingleColor.

Product_tags-display_rules.png


Conditions based on product variations

Show or hide fields & sections based on product variations. Below is the list of conditions available to display fields & sections based on product variation.

  1. Value equals to
  2. Value not equals to

Variable products are grouped using the product attributes function. Product attributes are briefly divided into two,

  1. Global Attributes
  2. Local Attributes

Global Attributes: Once defined, these attributes will be available to add for all the products. They will be listed in the attributes section of the product from where you can choose them from the dropdown.

Local Attributes: While global attributes are available to select throughout for all products, local attributes are those which are custom added to a particular product from the attributes section inside the product details.

Local_attribute.png

Example: Show field xyz if the product is sunglass of the color red. Here, the color is a local attribute.

display_rules


Conditions based on other field’s value

This option allows you to set conditions based on other field’s values. Below is the list of conditions available to display fields & sections based on other fields’ values.

  1. Is empty
  2. Is not empty
  3. Value equals to
  4. Value not equals to
  5. Value in
  6. Contains
  7. Not contains
  8. Value greater than
  9. Value less than
  10. Value starts with
  11. Value not starts with
  12. Date equals to
  13. Date not equals to
  14. Date after
  15. Date before
  16. Day equals to
  17. Day not equals to
  18. Is checked
  19. Is not checked
  20. Match expression

Conditions based on input fields (Text, Hidden, Password, and Textarea)

Follow the below steps for the field types like text, textarea, password, and hidden.

Textarea___pswd.png

  1. Choose the Show/Hide option from the drop-down to display/hide the specific field.
  2. From the Select field textbox, choose a specific field based on which the rule needs to be set.
  3. Select the required condition from the next drop-down.
  4. Provide the conditional data that should be satisfied for that particular field.
  5. Save the changes made.

Conditions based on option value

For Select and Radio

OPTION_VALUE.png

  1. Choose Show/Hide option from the drop-down to display/hide the specific field.
  2. From the Select box, pick the specific field based on which the rule has to be set.
  3. Choose the required condition from the next drop-down.
  4. Enter the option value in the input field at the right.
  5. Use the OR function to set condition rules based on more than one option value.
  6. Save the changes made.

Based on the Checkbox

Set display rules using the option ‘Is checked/ Is not checked‘. Follow the below steps to set a conditional field based on a checkbox.

CHECKBOX.png

  1. Choose Show/Hide from the drop-down to display or hide the field.
  2. From the Select box, pick the Checkbox field based on which the rule has to be set.
  3. Select the required condition Is Checked/Is not checked from the drop-down in the middle.
  4. Save the changes made.

Based on the Checkbox Group & Multi-Select

Chckbox_grp___mlti-slt.png

  1. Choose Show/Hide from the drop-down to display or hide the field.
  2. From the Select box, pick the field based on which the rule has to be set.
  3. Select a suitable condition from the drop-down in the middle.
  4. Enter the option text which needs to be satisfied for the field (Enter the value in the final input field.)
  5. Use the OR function to set condition rules based on more than one option value.
  6. Use comma separator to connect the option text with AND function.

Conditions based on Date Picker & Time picker

To set a rule based on the Date picker field type:

Date_picker_1.png

  1. Insert the date in the format ‘DD/MM/YYYY’.
  2. From the Select box, pick the field based on which the rule has to be set.
  3. Choose the required condition from the dropdown like ‘Day equals to/Day not equals to’.
  4. For setting a rule based on the day of a week enter the input values as the first three letters of the day after choosing the condition. (Example: Mon instead of Monday).

Note: The date format set for the field/section in the field properties will not be validated while setting as the rule.

To set a rule based on the Time picker field type:

Time_picker.png

  1. Enter the time in the format ‘HH:MM AM/PM’.
  2. From the Select box, pick the field based on which the rule has to be set.
  3. Choose the required condition from the dropdown like ‘value equals to/value not equals to’.
  4. Provide a specific time in the final textbox.

Note: Only the condition “equals to” and “value not equals to” will work. The time picker value entered in 24-hour format will not be validated.


Conditions based on Product Quantity

Follow the below steps while setting up a conditional rule based on the product quantity chosen:

discount_rules_based_product_quantity.png

  1. Go to Display rules, Choose Show/Hide from the display action dropdown.
  2. From the Select box, select Product Quantity.
  3. Select a suitable condition as per your requirement from the drop-down in the middle.
  4. Enter the quantity required for configuring the conditional rule in the input field at the right.

Save changes by clicking on the Save & Close.


Custom conditions

When the above-discussed options are not enough to set your required conditions, don’t worry you can set your own conditions using the below hooks.

Filter hook to set custom display rules for product fields.

apply_filters('thwepo_show_field', $show, $field_name);

Filter hook to set custom display rules for custom product sections.

apply_filters('thwepo_show_section', $show, $section_name);
Get the plugin

Quick Links

  • Try Demo
  • How to Download and Install Our Plugin ?
  • Manage License
  • Join our Facebook Community

On this page

  • General instructions to set display rules
  • To set display rules for product fields:
  • To set display rules for sections:
  • Conditions based on user role
  • Conditions based on products
  • Conditions based on product categories
  • Conditions based on product tags
  • Conditions based on product variations
  • Conditions based on other field's value
  • Conditions based on input fields (Text, Hidden, Password, and Textarea)
  • Conditions based on option value
  • For Select and Radio
  • Based on the Checkbox
  • Based on the Checkbox Group & Multi-Select
  • Conditions based on Date Picker & Time picker
  • To set a rule based on the Date picker field type:
  • To set a rule based on the Time picker field type:
  • Conditions based on Product Quantity
  • Custom conditions

This article posted in Extra Product Option for WooCommerce, Getting Started, Pro Documentation

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

ThemeHigh

We develop innovative WordPress plugins and themes for e-commerce and other WordPress websites.

Resources
  • Documentation
  • Support
  • Blog
  • Bestsellers
  • Affiliates
  • Partners
Policy Information
  • Terms & Conditions
  • Privacy Policy
  • Support Policy
  • Refunds Policy
  • Licenses
Security
Payment Options

© 2021 ThemeHigh. All rights reserved.

Terms and conditions, features, support, pricing, and service options subject to change without notice.