2.3 Setting Up Conditions

Setting Up Conditions

Conditions are the heart of Order Daemon’s intelligence. They define the specific criteria that must be met before an order is automatically completed. Think of conditions as your business rules translated into precise, automated logic.

What Are Conditions?

Conditions are the “IF” statements in your completion rules. When a trigger fires, Order Daemon evaluates all conditions to determine if the order qualifies for automatic completion. Only when ALL conditions in a rule are satisfied will the actions execute.

Quick Summary

  • Conditions within a rule use AND logic (all must pass)
  • Rules are evaluated by priority; first full match wins and stops further checks
  • Each condition can offer its own “match scope” (e.g., all products vs any product)
  • Keep heavy checks to a minimum; they run asynchronously but still affect throughput
  • Use the Insight Dashboard to see per-condition pass/fail reasons

Understanding Condition Logic

All Conditions Must Match

Order Daemon uses “AND” logic for conditions within a rule:

  • ✅ Condition 1 is true AND
  • ✅ Condition 2 is true AND
  • ✅ Condition 3 is true
  • = Actions execute

If any single condition fails, the entire rule is skipped.

First Rule Wins

When multiple rules exist:

  1. Rules are evaluated in priority order
  2. The first rule with ALL conditions met executes
  3. No further rules are checked for that order

Available Conditions

Free Conditions

Product Type

Checks: Whether products in the order match selected types

Options:

  • Virtual products (Free)
  • Downloadable products (Free)
  • Simple products (Premium)
  • Variable products (Premium)
  • Grouped products (Premium)
  • External/Affiliate products (Premium)
  • Subscription products (Premium – if plugin installed)
  • Other custom product types (Premium)

Match Modes:

  • All products must match selected types
  • At least one product must match selected types
  • No products should match selected types

Use cases:

  • Digital downloads that need immediate delivery
  • Online courses or software licenses
  • Service bookings without physical fulfillment

Example:

“All products are virtual OR downloadable” ensures only digital products complete automatically.

Product Category

Checks: Whether products belong to specific categories

Options:

  • Single category selection (Free)
  • Multiple category selection (Premium)

Match Types:

  • Any product matches (OR logic)
  • All products must match (AND logic)

Use cases:

  • Digital media categories (eBooks, music, videos)
  • Service categories (consultations, memberships)
  • Excluding specific categories from automation

Example:

“All products in ‘Digital Downloads’ category” targets only your digital inventory.

Order Total Amount

Checks: Order value against specified thresholds

Options:

  • Greater than amount
  • Less than amount
  • Equal to amount
  • Greater than or equal to amount
  • Less than or equal to amount

Use cases:

  • High-value order manual review
  • Free order instant completion
  • Tiered processing rules

Example:

“Order total less than $100” for automatic completion of smaller orders.

Premium Conditions 🔓

Customer Role

Checks: WordPress user role of the customer

Options:

  • Multiple role selection with checkboxes
  • Include guest customers option
  • Supports all WordPress and WooCommerce roles

Use cases:

  • VIP customer fast-track processing
  • Wholesale automatic approval
  • New customer restrictions
  • Guest customer handling

Example:

“Customer role is Wholesale OR VIP” for trusted buyer automation.

Payment Method

Checks: Which payment gateway was used

Options:

  • All configured payment gateways
  • Searchable multi-select interface
  • Gateway status indicators (Enabled/Disabled)
  • Support for custom payment plugins

Match Modes:

  • Order uses any of the selected gateways
  • Order uses all of the selected gateways
  • Order uses none of the selected gateways

Use cases:

  • Instant completion for trusted payment methods
  • Different rules for different payment providers
  • Excluding manual payment methods

Example:

“Payment method is PayPal OR Stripe” for trusted instant payments.

Shipping Method

Checks: Selected shipping option

Options:

  • All configured shipping methods from all zones
  • Searchable multi-select interface
  • Zone information included in labels
  • Support for shipping plugins

Match Modes:

  • Order uses any of the selected methods
  • Order uses all of the selected methods
  • Order uses none of the selected methods

Use cases:

  • Digital delivery with pickup option
  • Express shipping prioritization
  • Location-based rules

Example:

“Shipping method is Local Pickup” for products without physical shipping.

Specific Products

Checks: Whether order contains specific selected products

Options:

  • Searchable product selection with SKU and type info
  • Include product variations option
  • Support for all product types

Match Modes:

  • Order contains ANY of the selected products
  • Order contains ALL of the selected products
  • Order contains ONLY the selected products (no others)
  • Order contains NONE of the selected products

Use cases:

  • Product-specific automation rules
  • Exclusive product handling
  • Product restriction workflows

Example:

“Order contains ‘Premium Course Bundle'” for special handling of specific products.

Order Item Count

Checks: Number of items in the order

Options:

  • Greater than, less than, equal to, greater/equal, less/equal
  • Count unique products OR total quantity
  • Flexible threshold settings

Count Types:

  • Unique Products (line items)
  • Total Quantity (including quantities)

Use cases:

  • Bulk order processing
  • Single-item express handling
  • Quantity-based automation

Example:

“Order has exactly 1 unique product” for single-item express processing.

Configuring Conditions

Basic Setup

  1. Navigate to Order Daemon → Completion Rules
  2. Edit your rule or create new
  3. Locate the Conditions section
  4. Select condition types to add
  5. Configure each condition’s parameters
  6. Save your rule

Condition Parameters

Each condition type has specific parameters:

Note: Many conditions offer a Match Scope that determines whether ALL line items must match, ANY line item can match, or NONE should match. Choose the strictest option that reflects your intent to avoid over-matching.

Common parameters you may see across conditions:

  • Match Scope (all/any/none)
  • Include vs Exclude lists
  • Context (product vs variation, including guests, etc.)
Product Type Condition:
├── Type Selection (dropdown)
└── Match Logic (all/any)

Order Total Condition:
├── Comparison (greater/less/equal/between)
├── Amount Field(s)
└── Currency consideration

Category Condition:
├── Category Selection (hierarchical)
├── Include Subcategories (checkbox)
└── Match Logic (all/any/none)

Multiple Conditions Example

Rule: “Premium Digital Downloads”

  • ✅ All products are virtual/downloadable
  • ✅ Order total > $50
  • ✅ Payment method is instant (PayPal/Stripe)
  • ✅ Customer role is not ‘Suspicious’
  • = Complete order immediately

Advanced Condition Patterns

Pattern 1: Tiered Processing

Create multiple rules with different order total conditions:

Rule 1: Orders < $50 → Auto-complete
Rule 2: Orders $50-$500 → Require one approval
Rule 3: Orders > $500 → Manual review only

Pattern 2: Product Mix Handling

Handle orders with both digital and physical products:

Rule:

  • At least one virtual product
  • Shipping method is “Digital + Physical”
  • = Complete digital portion only

Pattern 3: Customer Trust Levels

Different automation based on customer history:

New Customers:

  • First order
  • Order total < $25
  • = Complete with verification

Trusted Customers:

  • Customer role is “Verified”
  • Any order total
  • = Complete immediately

Condition Evaluation

How Order Daemon Checks Conditions

  1. Load Order Data: Gather all order information
  2. Initialize Conditions: Load rule’s condition set
  3. Sequential Evaluation: Check each condition
  4. Short-Circuit Logic: Stop at first failure
  5. Result Determination: All pass = true, any fail = false

Performance Considerations

  • Conditions are evaluated in the order displayed
  • Place most restrictive conditions first
  • Complex conditions may impact processing time
  • Use caching for expensive checks

Troubleshooting Conditions

Common Issues

Condition Not Matching

Symptoms: Orders not completing despite seeming to match

Check:

  • Product variations and attributes
  • Category inheritance and subcategories
  • Exact payment method names
  • Customer role assignments

Over-Matching

Symptoms: Orders completing when they shouldn’t

Check:

  • Condition logic (AND vs OR)
  • Missing restrictive conditions
  • Rule priority ordering
  • Default values and edge cases

Debugging Tools

Audit Trail Details

  1. Shows exact condition evaluation
  2. Lists why conditions passed/failed
  3. Provides order context

Test Mode

Dry-run rules without completing orders

See which conditions match

Verify logic before activation

WP-CLI Testing

wp odcm rule test --order-id=123

Best Practices

Do’s

  • ✅ Start simple, add complexity gradually
  • ✅ Test with real order data
  • ✅ Document complex condition logic
  • ✅ Use descriptive rule names
  • ✅ Review audit logs regularly

Don’ts

  • ❌ Don’t create overlapping conditions
  • ❌ Avoid too many conditions in one rule
  • ❌ Don’t rely on default values
  • ❌ Never skip testing edge cases

Condition Development

Custom Conditions (Developer)

Add custom conditions via filters:

/**
 * Filter: Register custom conditions for Order Daemon.
 *
 * @param array<string,array{label:string,callback:callable,fields:array<int,string>}> $conditions
 * @return array<string,array{label:string,callback:callable,fields:array<int,string>}>
 */
add_filter('odcm_custom_conditions', function($conditions) {
    $conditions['order_source'] = [
        'label' => 'Order Source',
        // Signature: function(\WC_Order $order, array $params): bool
        'callback' => 'check_order_source',
        'fields' => ['source_type']
    ];
    return $conditions;
});

Extending Existing Conditions

Modify condition behavior:

add_filter('odcm_condition_product_type_check', function($result, $order, $params) {
    // Custom logic here
    return $result;
}, 10, 3);

Next Steps

With conditions configured, you’re ready to:

Remember: Well-crafted conditions are the key to reliable automation. Take time to think through your business logic and test thoroughly before deploying to production.

Was this article helpful?

  • Loading...
Table of Contents
  • Loading...