2.2 Understanding Triggers

Triggers are the starting point of every completion rule in Order Daemon. They define when the plugin should evaluate whether an order should be automatically completed. Think of triggers as the events that wake up the Order Daemon and tell it to check your rules.

What Are Triggers?

A trigger is a specific WooCommerce event that initiates the rule evaluation process. When a trigger fires, Order Daemon:

  1. Receives the order information
  2. Checks all active completion rules
  3. Evaluates conditions for matching rules
  4. Executes actions if conditions are met

Available Triggers

Free Triggers

Order Status: Processing (Default)

Hook: woocommerce_order_status_processing

This is the primary free trigger available in Order Daemon. It fires when an order status changes to “Processing” and is ideal for most standard automations.

When to use:

  • Most common scenario for auto-completion
  • Digital products and services
  • Standard WooCommerce workflows
  • Any scenario where processing status should trigger completion

Example scenario:

A customer purchases a digital course. When their payment is processed and the order moves to “Processing” status, the order completes automatically, granting immediate access to the course materials.

Internal Scheduling Hook (Automatic)

Hook: woocommerce_checkout_order_processed

This hook is used internally by Order Daemon to schedule asynchronous rule evaluation via WooCommerce Action Scheduler. It does not complete orders by itself and is not exposed as a selectable trigger in the Rule Builder.

Why it matters:

  • Ensures heavy logic runs off the checkout request
  • Improves reliability on high-traffic stores
  • Guarantees that your selected triggers are evaluated safely in the background

Note: You do not need to configure this. It is always active and complements the user-selectable triggers below.

Premium Triggers 🔓

Payment Complete

Hook: woocommerce_payment_complete

Advanced trigger that fires specifically when payment is completed, regardless of order status. This is a premium feature requiring a paid license.

When to use:

  • Subscription renewals and complex payment gateways
  • Delayed capture scenarios
  • Payment-specific automation workflows

Example scenario:

A subscription service needs to activate immediately upon payment confirmation, regardless of whether the order goes to “Processing” or “On Hold” first.

Order Status: On Hold

Hook: woocommerce_order_status_on-hold

Fires when an order transitions to “On Hold” status. This is a premium feature for specialized workflow handling.

When to use:

  • Bank transfer payments that you pre-approve
  • Check payments from trusted customers
  • Manual payment verification workflows

Example scenario:

Regular wholesale customers pay by bank transfer. Their orders go “On Hold” but you want to complete them immediately based on their trusted status.

Order Status: Completed

Hook: woocommerce_order_status_completed

Fires when an order status changes to “Completed”. Perfect for post-fulfillment actions and follow-up workflows.

When to use:

  • Post-fulfillment notifications
  • Customer satisfaction surveys
  • Loyalty program point awards
  • Follow-up marketing campaigns

Example scenario:

After an order is marked as completed, automatically send a review request email and award loyalty points to the customer.

Order Status: Pending Payment

Hook: woocommerce_order_status_pending

Fires when an order status changes to “Pending Payment”. Useful for payment reminders and abandoned cart recovery.

When to use:

  • Payment reminder workflows
  • Abandoned cart recovery
  • Manual payment method follow-ups
  • Order expiration notifications

Example scenario:

When a bank transfer order goes to “Pending Payment”, automatically send payment instructions and set up reminder emails.

Order Status: Failed

Hook: woocommerce_order_status_failed

Fires when an order status changes to “Failed”. Ideal for failure notifications and recovery workflows.

When to use:

  • Payment failure notifications
  • Recovery workflow automation
  • Customer support ticket creation
  • Alternative payment method suggestions

Example scenario:

When a payment fails, automatically notify the customer with alternative payment options and create a support ticket for follow-up.

Order Status: Cancelled

Hook: woocommerce_order_status_cancelled

Fires when an order status changes to “Cancelled”. Perfect for cleanup actions and notifications.

When to use:

  • Inventory restoration workflows
  • Cancellation confirmation emails
  • Refund processing automation
  • Analytics and reporting updates

Example scenario:

When an order is cancelled, automatically restore inventory, send a cancellation confirmation, and update sales analytics.

Order Status: Refunded

Hook: woocommerce_order_status_refunded

Fires when an order status changes to “Refunded”. Useful for refund processing and notifications.

When to use:

  • Refund confirmation workflows
  • Customer satisfaction follow-ups
  • Inventory management updates
  • Financial reporting automation

Example scenario:

When a refund is processed, automatically send confirmation to the customer and update inventory levels for returned products.

Any Status Change

Hook: woocommerce_order_status_changed

Advanced trigger that fires when order status changes between any specified statuses. Provides comprehensive control over order status transitions.

When to use:

  • Complex workflow automation
  • Multi-step order processing
  • Custom status transition logic
  • Advanced business rule implementation

Example scenario:

Create rules that trigger only when orders move from “Processing” to “Shipped” or from “On Hold” to “Processing”, with different actions for each transition.

Custom Trigger Events

Hook: Custom WordPress actions

Create triggers based on any WordPress action in your system.

When to use:

  • Integration with third-party plugins
  • Custom checkout flows
  • Specialized business logic

Example scenarios:

  • Membership plugin activation
  • Booking confirmation
  • Custom API webhook receipt

How Triggers Work

The Execution Flow

1. Customer Action
        ↓
2. WooCommerce Event
        ↓
3. Trigger Fires
        ↓
4. Order Daemon Activates
        ↓
5. Rules Evaluated
        ↓
6. Conditions Checked
        ↓
7. Actions Executed

Asynchronous Processing

Order Daemon uses WooCommerce’s Action Scheduler for trigger processing:

  • Scheduling hook: woocommerce_checkout_order_processed (automatic)
  • Non-blocking: Triggers don’t slow down checkout
  • Reliable: Failed processes automatically retry
  • Scalable: Handles high-volume stores efficiently
  • Traceable: Every trigger event is logged
  • Deduplicated: Prevents duplicate processing when multiple hooks fire close together

WooCommerce Lifecycle: Quick Map

  • Order Creation → schedules async evaluation via woocommerce_checkout_order_processed (internal; non-selectable)
  • Payment Complete → primary trigger woocommerce_payment_complete
  • Status Transitions → optional triggers woocommerce_order_status_on-hold, woocommerce_order_status_processing

Gateway Patterns at a Glance

Different payment gateways trigger events at different lifecycle stages:

  • Credit Cards: Usually trigger Payment Complete immediately
  • Bank Transfers: Often go to On Hold first, then Processing after manual verification
  • PayPal: May have delayed confirmation depending on configuration

Choosing the Right Trigger

Decision Matrix

Note: The checkout scheduling hook woocommerce_checkout_order_processed) runs automatically and is not selectable as a trigger.

TriggerBest ForAvoid When
Processing (Free)Most digital products, standard workflowsComplex payment scenarios
Payment Complete (Premium)Subscription renewals, complex gatewaysSimple processing workflows
On Hold (Premium)Trusted customers, manual paymentsAutomated payment gateways
Custom (Premium)Unique business requirementsStandard WooCommerce flows work

Common Patterns

Pattern 1: Standard Digital Delivery

  • Trigger: Processing (Free)
  • Condition: All products are virtual/downloadable
  • Result: Automatic order completion when payment processes

Pattern 2: Advanced Payment Handling

  • Trigger: Payment Complete (Premium)
  • Condition: Specific payment gateway
  • Result: Immediate completion regardless of order status

Pattern 3: Trusted Customer Fast-Track

  • Trigger: On Hold (Premium)
  • Condition: Customer role is “Wholesale”
  • Result: Skip manual verification for known customers

Trigger Configuration

In the Rule Builder

  1. Navigate to Order Daemon → Completion Rules
  2. Click Add New Rule or edit existing
  3. In the Triggers section, select your trigger
  4. Configure any trigger-specific settings
  5. Save and activate your rule

Multiple Triggers

Premium users can select multiple triggers for a single rule:

  • Rule evaluates when ANY selected trigger fires
  • Useful for covering multiple payment scenarios
  • Prevents duplicate processing with built-in safeguards (idempotent checks and event de-duplication)

Advanced Trigger Concepts

Trigger Priority

When multiple rules use the same trigger:

  1. Rules execute in priority order (menu_order)
  2. First matching rule wins
  3. Subsequent rules don’t process that order

Trigger Context

Each trigger provides different context data:

// Checkout Order Processed (internal scheduling) provides:
- Order ID
- Checkout posted data
- Customer/session context
  
// Processing Status (free) provides:
- Order ID
- Previous status
- New status
- Status change context
  
// Payment Complete (premium) provides:
- Order ID
- Transaction ID
- Payment method details
  
// Status transitions (premium) provide:
- Order ID
- Previous status
- New status
- Status change note

Custom Trigger Development

Developers can add custom triggers using the odcm_custom_triggers filter:

add_filter('odcm_custom_triggers', function($triggers) {
$triggers['my_custom_event'] = [
'label' => 'My Custom Event',
'hook' => 'my_plugin_special_event',
'description' => 'Fires when special event occurs'
    ];
return $triggers;
});

Troubleshooting Triggers

Common Issues

Trigger Not Firing
  • Check rule is published/active
  • Verify trigger event actually occurs
  • Review audit logs for processing attempts
  • Ensure Action Scheduler is running
Trigger Fired But No Completion
  • Remember: First match wins — a higher-priority rule may have matched and stopped processing
  • Confirm the rule’s conditions are actually met for the order
  • Verify the rule is not restricted by schedule, customer role, or product scope
  • Check logs for “conditions not met” entries
Multiple Completions
  • Check for duplicate rules
  • Verify trigger conditions
  • Review rule priorities
  • Enable detailed logging
Delayed Processing
  • Normal for asynchronous processing (usually < 60 seconds)
  • Check Action Scheduler queue
  • Verify server cron configuration
  • Monitor system resources

Debugging Tools

  1. Audit Trail: Shows all trigger events and outcomes
  2. WP-CLI: wp odcm log list --type=trigger_fired
  3. Developer Mode: Enable ODCM_DEBUG for verbose logging

Best Practices

Do’s

  • ✅ Use Processing trigger for most digital products (free tier)
  • ✅ Test triggers in staging environment first
  • ✅ Monitor audit logs after deployment
  • ✅ Document custom trigger logic

Don’ts

  • ❌ Don’t use multiple triggers without clear purpose
  • ❌ Avoid custom triggers for standard WooCommerce events
  • ❌ Don’t bypass WooCommerce’s payment confirmation
  • ❌ Never modify core trigger behavior

WooCommerce Order Lifecycle Integration

Order Daemon integrates deeply with WooCommerce’s order processing pipeline, listening to key events throughout an order’s journey from creation to completion. Understanding this integration helps you choose optimal triggers and troubleshoot processing issues.

Order Lifecycle Stages and Available Triggers

Order Placement → Payment Processing → Fulfillment → Completion

Stage 1: Order Creation

  • Internal Event: woocommerce_checkout_order_processed (automatic scheduling)
  • Purpose: Order Daemon schedules background evaluation of all your rules
  • When: Immediately after order is created, regardless of payment status

Stage 2: Status Transitions

  • Available Triggers:
    • Processing Status woocommerce_order_status_processing) ✅ Free
    • On Hold Status woocommerce_order_status_on-hold) 🔓 Premium
  • Purpose: Handle order status changes and workflow requirements
  • When: As orders move through WooCommerce’s status progression

Stage 3: Payment Events

  • Available Trigger: Payment Complete woocommerce_payment_complete) 🔓 Premium
  • Purpose: Advanced payment handling for complex workflows
  • When: After payment gateway confirms successful transaction

How Order Daemon Fits Into WooCommerce’s Flow

Order Daemon schedules background jobs at safe, early points and performs heavy logic asynchronously using Action Scheduler. It listens for:

  • Order creation (scheduling only; no completion) to set up async evaluation
  • Payment complete to initiate primary completion checks
  • Status transitions (on-hold, processing) for workflows where gateways or admins change status before/after payment
    Deduplication prevents duplicate processing when multiple hooks fire close together.

Multiple Payment Scenarios

Different payment gateways trigger events at different lifecycle stages:

  • Credit Cards: Usually trigger Payment Complete immediately
  • Bank Transfers: Often go to On Hold first, then Processing after manual verification
  • PayPal: May have delayed confirmation depending on configuration

Understanding these patterns helps you choose the right triggers for your specific payment setup.

Next Steps

Now that you understand triggers, you’re ready to:

Remember: Triggers are just the beginning. The real power comes from combining them with precise conditions and actions to create sophisticated automation rules that match your exact business needs.

Was this article helpful?

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