Skip to content

Conditional Visibility

Conditional Visibility lets you show or hide fields based on what the customer has already selected in the same Option Group. Use it to build branching option flows that adapt in real time as the customer interacts.

Visibility tab inside the Addon Builder showing condition rules configured for a field


How It Works

Each field has a Visibility tab in the Addon Builder. You configure a set of rules (conditions) that are evaluated against the other fields in the same group. If the conditions are met, the field is either shown or hidden depending on your action setting.

On the frontend, the JavaScript engine re-evaluates all conditions in real time as the customer interacts. Fields appear and disappear without any page reload.

On the backend (at cart submission), the same conditions are re-evaluated server-side by ConditionEvaluator.php to ensure:

  • Hidden fields are not validated as required
  • Hidden fields do not contribute to pricing calculations
  • Hidden fields are not saved to the cart or order

Setting Up Conditions

Inside the Visibility tab of any field:

Step 1 — Enable Conditions

Toggle Enable Conditional Logic to on.

Step 2 — Choose the Action

ActionEffect
Show this field when…Field is hidden by default; shown only when conditions are met
Hide this field when…Field is visible by default; hidden when conditions are met

Step 3 — Set Match Type

Match TypeLogic
ALL (AND)Every single rule must be true for the action to trigger
ANY (OR)At least one rule must be true for the action to trigger

Step 4 — Add Rules

Click Add Rule. Each rule has three parts:

PartDescription
FieldSelect which other field in the group to watch
OperatorThe comparison to perform
ValueThe value to compare against

Supported Operators

OperatorMeaningWorks With
== (equals)Value exactly matchesAll fields
!= (not equals)Value does not matchAll fields
> (greater than)Numeric comparisonNumber fields
< (less than)Numeric comparisonNumber fields
>= (greater than or equal)NumericNumber fields
<= (less than or equal)NumericNumber fields
containsValue appears in the selectionCheckbox (multi), text
not containsValue does not appear in selectionCheckbox (multi), text
is emptyNo value submittedAll fields
is not emptyA value has been submittedAll fields

Examples

Show "Engraving Text" only if "Add Engraving?" is checked

Action: Show this field when...
Match: ALL

Rule 1:
  Field:    Add Engraving?
  Operator: == (equals)
  Value:    1

The 1 value is what a single checkbox submits when checked.


Hide shipping note if "In-store pickup" is selected

Action: Hide this field when...
Match: ALL

Rule 1:
  Field:    Delivery Method
  Operator: == (equals)
  Value:    pickup

Show "Rush fee" warning only if quantity is 10 or more

Action: Show this field when...
Match: ALL

Rule 1:
  Field:    Quantity Needed
  Operator: >= (greater than or equal)
  Value:    10

Show discount field if EITHER coupon code OR loyalty badge is selected

Action: Show this field when...
Match: ANY

Rule 1:
  Field:    Promo Code
  Operator: is not empty

Rule 2:
  Field:    Loyalty Tier
  Operator: contains
  Value:    gold

Initial Render (No Layout Shift)

When the product page loads, Smart Product Options and Addons sets the initial visibility of each conditional field server-side before the page renders. Fields set to "show when…" start hidden (CSS class ob-hidden). This prevents the flash of an incorrect state while JavaScript initialises.


Conditions and Validation

Fields that are hidden by conditions are fully skipped during:

  • Required field validation at add-to-cart
  • Pricing calculations
  • Cart session storage
  • Order item metadata

A hidden field never appears on the cart page, checkout, or order — even if it has a required setting or a price attached.

Cross-Group Conditions Not Supported

Conditions can only reference other fields within the same Option Group. You cannot create conditions that watch fields in a different group.

Released under the GPL-2.0+ License.