Rules Engine
Create conditional rules that automatically manipulate editor canvas items based on design content in the Print Editor.
The Rules Engine lets you define conditional logic that automatically modifies canvas items in the Print Editor based on the state of other items. Rules evaluate conditions about design elements (such as whether a text field is empty, an image has been placed, or a field has a certain number of characters) and then perform actions like anchoring items together, swapping images, moving elements, or changing text, fonts, and colors.
Rules are organized into rule groups, and each group contains one or more individual rules. A rule group is assigned to a product via the product's metadata, so when a customer opens that product in the Print Editor, the rules are loaded and evaluated in real time as the design changes. This is useful for dynamic layouts where element positioning or visibility depends on user input.
View Rule Groups
- From your Unified Admin, go to Print Editor > Rules Engine.
- The page displays a paginated grid of all rule groups for the current storefront.
- Use the Search button to filter groups by name.
- Rule groups that have no rules defined are highlighted with a blue background tint to indicate they need configuration.
Rule Group List Columns
| Column | Description |
|---|---|
| Id | The unique identifier for the rule group. |
| Name | The name of the rule group. Groups without a name display as "Unnamed Rule Group". |
| Action | Menu with Edit and Delete options. |
Add a Rule Group
- Click the Add New Rule Group button in the top-right corner.
- You are navigated to the rule editor page with an empty rule group.
- Enter a Rule Group Name in the field at the top.
- Click Add New Rule to create your first rule within the group.
- Click Save Rule Group when finished.
Edit a Rule Group
- Click the Action menu (three-dot icon) on the rule group row.
- Select Edit to open the rule editor page.
The rule editor has a three-column layout:
- Left panel: Lists all rules in the group. Click a rule to select it. Click the X button to remove a rule from the group.
- Right panel: Shows the selected rule's configuration with name, description, conditions, and actions.
Rule Fields
| Field | Description |
|---|---|
| Rule Group Name | The name for the entire rule group. This is what appears in the list view and is used when assigning the group to products. |
| Rule Name | A descriptive name for an individual rule within the group (e.g., "Hide subtitle when empty"). |
| Description | An optional description explaining what the rule does. |
Visual vs. Code Mode
Each rule can be edited in two modes, toggled with the Visual and Code buttons:
- Visual: A form-based builder for creating conditions and actions without writing JSON.
- Code: Displays the raw JSON representation of all rules in the group. Useful for debugging or advanced editing.
Conditions
Conditions define when a rule should fire. Each condition evaluates a property of a target canvas item. Multiple conditions can be chained using logical operators.
Click the + button in the Conditions section to add a new condition.
Condition Fields
| Field | Description |
|---|---|
| Modifier | The logical operator connecting this condition to the previous one. Options: AND, OR, XOR. The first condition displays "If" instead of a modifier. |
| Target | The tag name of the canvas item to evaluate (e.g., a text field or image placeholder tag name as defined in the editor template). |
| Property | The property to check on the target item. See the Property Options table below. |
| Comparison | The comparison operator. Only shown when the selected property supports a value comparison. Options: equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to. |
| Compare to | The value to compare against. Only shown when the selected property supports a value comparison. |
Property Options
| Property | Description | Shows Comparison |
|---|---|---|
| is empty | True when the target item has no content. | No |
| is not empty | True when the target item has content. | No |
| has rows | True when the target text item has a number of rows that can be compared. | Yes |
| has characters | True when the target text item has a character count that can be compared. | Yes |
| has a width | True when the target item has a width that can be compared. | Yes |
| exists | True when the target item exists on the canvas. | No |
| has an image id | True when the target image item has an assigned image ID that can be compared. | Yes |
Actions
Actions define what happens when all conditions are met. Each action targets a canvas item by its tag name and performs a transformation.
Click the + button in the Actions section to add a new action.
Action Types
| Action Type | Description | Additional Fields |
|---|---|---|
| anchor | Pins the target item relative to another item with an optional offset. Used for dynamic positioning where one element follows another. | Pin Side (to right of, to left of) Pin To (item tag name) Offset (distance between items) |
| swap image | Replaces the target image with a different image by ID. | Image Id |
| erase | Removes the target item from the canvas. | None |
| move by | Moves the target item by a relative offset from its current position. | Move X, Move Y |
| move to | Moves the target item to an absolute position on the canvas. | Move X, Move Y |
| change color to | Changes the color of the target item. | Color (in #rrggbb format) |
| change font to | Changes the font of the target text item. | Font Name |
| change text to | Replaces the text content of the target text item. | Text |
| auto fit text | Automatically adjusts the target text item to fit within its bounding box. | None |
All action types require a Target (item tag name) field that identifies which canvas item the action applies to.
Delete a Rule Group
- Click the Action menu (three-dot icon) on the rule group row.
- Select Delete.
- Confirm the deletion in the confirmation dialog.
Deleting a rule group soft-deletes the record (sets IsDeleted to true). Products that reference the deleted group will no longer load those rules in the editor.
Associations
Print Store
| Area | Effect |
|---|---|
| Product Configuration | Rule groups are assigned to products through the Product.Rules.Assigned object metadata, which stores the rule group ID. When a customer opens the product in the Print Editor, the storefront loads the assigned rule group's JSON rules and sends them to the editor client. |
Related Pages
- Products — assign rule groups to products via product metadata
- Simple Editor — the streamlined editor mode where rules evaluate in real time
- Admin Mode — set tag names on items that rules target in conditions and actions
- Autofill Profiles — auto-populate fields that rules can then evaluate