Order Daemon provides strategic integration points through WordPress hooks, allowing you to extend order management functionality without modifying plugin files. These hooks are designed for common integration scenarios that store owners and developers need.
Essential Filter Hooks
odcm_order_has_conflicts
The most important hook for order management control.
This filter allows you to prevent Order Daemon from processing specific orders based on your business logic.
Parameters:
$has_conflicts
(bool): Returntrue
to skip processing,false
to allow$order_id
(int): The WooCommerce order ID being evaluated
Common Use Cases:
- Skip subscription orders that need manual review
- Exclude high-value orders requiring approval
- Prevent processing for specific product types
- Integrate with external fulfillment systems
Example: Skip subscription orders
add_filter('odcm_order_has_conflicts', 'skip_subscription_orders', 10, 2);
function skip_subscription_orders($has_conflicts, $order_id) {
// Respect existing conflicts
if ($has_conflicts) {
return true;
}
$order = wc_get_order($order_id);
if (!$order) {
return $has_conflicts;
}
// Skip if WooCommerce Subscriptions is active and order contains subscription
if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order)) {
// Log the reason for transparency
odcm_log_custom_event(
"Order #{$order_id} skipped: Contains subscription products",
['reason' => 'subscription_requires_manual_review'],
$order_id,
'info'
);
return true;
}
return false;
}
Example: Skip high-value orders
add_filter('odcm_order_has_conflicts', 'skip_high_value_orders', 10, 2);
function skip_high_value_orders($has_conflicts, $order_id) {
if ($has_conflicts) {
return true;
}
$order = wc_get_order($order_id);
if (!$order) {
return $has_conflicts;
}
// Skip orders over $500 for manual review
if ($order->get_total() > 500) {
odcm_log_custom_event(
"Order #{$order_id} skipped: High value order requires manual review",
['order_total' => $order->get_total(), 'threshold' => 500],
$order_id,
'info'
);
return true;
}
return false;
}
odcm_capture_gateway_context_{$gateway_id}
Extend payment gateway context for Block Checkout compatibility. This is useful for payment gateway developers or stores using custom payment methods.
Parameters:
$context
(array): Current payment context$order
(WC_Order): The order object$request_data
(array): Store API request data
Example: Capture Stripe payment context
add_filter('odcm_capture_gateway_context_stripe', 'capture_stripe_payment_details', 10, 3);
function capture_stripe_payment_details($context, $order, $request_data) {
// Add Stripe-specific payment information
$context['stripe_payment_intent'] = $order->get_meta('_stripe_intent_id');
$context['stripe_customer_id'] = $order->get_meta('_stripe_customer_id');
return $context;
}
Action Hooks for Integration
odcm_audit_log_recorded
Fires after any audit log entry is recorded, perfect for integrating with external monitoring, notifications, or business intelligence systems.
Parameters:
$log_id
(int): The database ID of the log entry$log_data
(array): Complete log entry data
Example: Send error alerts to Slack
add_action('odcm_audit_log_recorded', 'send_order_errors_to_slack', 10, 2);
function send_order_errors_to_slack($log_id, $log_data) {
// Only process error-level events
if ($log_data['status'] !== 'error') {
return;
}
$slack_webhook = 'https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK';
wp_remote_post($slack_webhook, [
'body' => json_encode([
'text' => "🚨 Order Processing Error",
'attachments' => [[
'color' => 'danger',
'fields' => [
['title' => 'Order ID', 'value' => $log_data['order_id'], 'short' => true],
['title' => 'Error', 'value' => $log_data['summary'], 'short' => false],
['title' => 'Time', 'value' => $log_data['timestamp'], 'short' => true]
]
]]
]),
'headers' => ['Content-Type' => 'application/json']
]);
}
Example: Sync completion data to CRM
add_action('odcm_audit_log_recorded', 'sync_completions_to_crm', 10, 2);
function sync_completions_to_crm($log_id, $log_data) {
// Only process successful order completions
if ($log_data['event_type'] !== 'order_completed' || $log_data['status'] !== 'success') {
return;
}
$order = wc_get_order($log_data['order_id']);
if (!$order) {
return;
}
// Send to your CRM system
wp_remote_post('https://your-crm.com/api/orders', [
'body' => json_encode([
'order_id' => $order->get_id(),
'customer_email' => $order->get_billing_email(),
'total' => $order->get_total(),
'completed_at' => $log_data['timestamp'],
'completion_method' => 'automated'
]),
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . get_option('your_crm_api_key')
]
]);
}
Custom Event Logging API
Track your integrations and custom workflows using Order Daemon’s audit system.
odcm_log_custom_event()
Log custom events that appear in the Order Daemon audit trail alongside system events.
Parameters:
$summary
(string): Human-readable event description$payload
(array|null): Optional structured data$order_id
(int|null): Optional order ID association$status
(string): Event status (‘success’, ‘error’, ‘warning’, ‘info’)$event_type
(string|null): Optional custom event type identifier
Example: Track external integrations
// Log successful API integration
odcm_log_custom_event(
'Customer data synchronized with CRM',
[
'crm_system' => 'salesforce',
'customer_id' => 'SF_12345',
'sync_duration_ms' => 1250
],
$order_id,
'success',
'crm_sync'
);
// Log integration failure with retry information
odcm_log_custom_event(
'Failed to sync order with inventory system',
[
'error_code' => 'TIMEOUT',
'retry_count' => 3,
'next_retry' => current_time('mysql', true)
],
$order_id,
'error',
'inventory_sync_failed'
);
Registry Extension API
Extend Order Daemon with custom triggers, conditions, and actions that appear in the rule builder.
Adding Custom Components
// Register during plugin initialization
add_action('init', 'register_my_order_components');
function register_my_order_components() {
$registry = odcm_get_registry_instance();
// Add custom condition for order value
$registry->register_condition([
'id' => 'order_value_threshold',
'label' => __('Order Value Threshold', 'my-plugin'),
'description' => __('Check if order exceeds specific value', 'my-plugin'),
'capability' => 'condition_order_value', // Required for entitlement system
'render_callback' => 'render_order_value_condition'
]);
// Add custom action for external notification
$registry->register_action([
'id' => 'notify_warehouse',
'label' => __('Notify Warehouse', 'my-plugin'),
'description' => __('Send notification to warehouse system', 'my-plugin'),
'capability' => 'action_warehouse_notify',
'render_callback' => 'render_warehouse_action'
]);
}
function render_order_value_condition($rule_data) {
$threshold = isset($rule_data['value_threshold']) ? $rule_data['value_threshold'] : '';
?>
<label>
<?php _e('Minimum Order Value:', 'my-plugin'); ?>
<input type="number" name="value_threshold" value="<?php echo esc_attr($threshold); ?>" step="0.01" min="0">
</label>
<?php
}
Best Practices for Integration
Performance Guidelines
- Keep hook callbacks lightweight and fast
- Use WordPress transients for caching expensive operations
- Avoid database queries in frequently called hooks
- Log important events but avoid excessive logging
Security Best Practices
// Always validate order objects
$order = wc_get_order($order_id);
if (!$order) {
return;
}
// Check user capabilities for admin operations
if (!current_user_can('manage_woocommerce')) {
return;
}
// Sanitize user input
$custom_value = sanitize_text_field($_POST['custom_field']);
// Use try-catch for external API calls
try {
$result = my_external_api_call($data);
} catch (Exception $e) {
odcm_log_custom_event(
'External API call failed: ' . $e->getMessage(),
['error_details' => $e->getTraceAsString()],
$order_id,
'error'
);
}
Compatibility Checks
// Check for plugin dependencies
if (!class_exists('WooCommerce')) {
return;
}
// Check for specific plugin features
if (!function_exists('wcs_order_contains_subscription')) {
return; // WooCommerce Subscriptions not available
}
Common Integration Patterns
External System Notifications
Use odcm_audit_log_recorded
to trigger notifications when specific events occur:
add_action('odcm_audit_log_recorded', 'notify_external_systems', 10, 2);
function notify_external_systems($log_id, $log_data) {
// Only process successful order completions
if ($log_data['event_type'] === 'order_completed' && $log_data['status'] === 'success') {
// Trigger your external system notification
my_external_system_notify($log_data['order_id']);
}
}
Conditional Order Processing
Use odcm_order_has_conflicts
to implement business logic:
add_filter('odcm_order_has_conflicts', 'check_business_rules', 10, 2);
function check_business_rules($has_conflicts, $order_id) {
if ($has_conflicts) {
return true; // Respect existing conflicts
}
$order = wc_get_order($order_id);
// Skip orders requiring manual review
if ($order->get_total() > 1000 || has_custom_products($order)) {
odcm_log_custom_event(
"Order #{$order_id} requires manual review",
['reason' => 'business_rule_exception'],
$order_id,
'info'
);
return true;
}
return false;
}
This streamlined hooks and filters system focuses on the most practical integration points for WordPress developers managing WooCommerce orders.