DOCS

v1.3.28
 // Pro v1.2.20

 · Latest

Docs/Integrations/Scheduled Automations

Scheduled Automations

Overview

Order Daemon’s rules are event-driven – they fire when something happens to an order. You can add time-based scheduling by pairing Order Daemon with cron-job.org, a free external cron service that sends HTTP requests on a schedule.

This guide covers three ways to use cron-job.org with Order Daemon:

  1. Reliable WP-Cron – prevent delayed processing on low-traffic stores
  2. Webhook health monitoring – get alerted before your payment processor does
  3. Scheduled rule triggers – drive time-based automations

1. Reliable WP-Cron

WordPress’s built-in scheduler (WP-Cron) only runs when someone loads a page. On low-traffic stores, scheduled tasks – subscription renewals, Action Scheduler jobs – can be delayed by minutes or hours.

The fix: disable visitor-triggered WP-Cron and replace it with an external ping.

Step 1 – Disable the visitor-triggered scheduler.

Add to wp-config.php:

define('DISABLE_WP_CRON', true);

Warning: Once this constant is set, scheduled tasks will not run unless your external cron ping is active. Set up the cron-job.org job before or immediately after adding this constant.

Step 2 – Create a cron-job.org job.

SettingValue
URLhttps://yoursite.com/?doing_wp_cron
Request methodGET
ScheduleEvery 5 minutes
Execution timeout30 seconds

Step 3 – Verify.

wp cron event list

If the list shows events with future timestamps, the scheduler is running.

2. Webhook health monitoring

Order Daemon exposes a health endpoint:

GET https://yoursite.com/wp-json/odcm/v1/webhooks/health

It returns HTTP 200 when the plugin is active and the webhook receiver is reachable. Poll it every 15 minutes to catch problems before Stripe or PayPal starts retrying.

Create a cron-job.org job:

SettingValue
URLhttps://yoursite.com/wp-json/odcm/v1/webhooks/health
Request methodGET
ScheduleEvery 15 minutes
Failure notificationsEnable – cron-job.org emails you on non-200 responses

Healthy response:

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00+00:00",
  "version": "1.2.0",
  "endpoints": { "paypal": true, "stripe": true, "generic": true }
}

3. Scheduled rule triggers via Generic webhook

Pro: Generic webhook triggers require an active Pro licence.

You can use cron-job.org as an external clock: it POSTs to a Generic webhook on a schedule, which fires the trigger and runs your rule.

Step 1 – Create a Generic webhook connection.

Go to Order Daemon → Webhooks and create a new Generic connection. Name it descriptively, for example nightly-sweep. Your webhook URL will be:

https://yoursite.com/wp-json/odcm/v1/webhooks/generic/nightly-sweep

Step 2 – Create a rule.

Create a rule with the Generic webhook trigger and select the nightly-sweep connection. Add conditions and actions, then publish.

Step 3 – Configure cron-job.org.

SettingValue
URLhttps://yoursite.com/wp-json/odcm/v1/webhooks/generic/nightly-sweep
Request methodPOST
Content-Type headerapplication/json
Request bodySee below

Request body:

{"event_type":"custom_event","metadata":{"source":"cron-job.org","label":"nightly-sweep"}}

Optional: HMAC signing

To verify that only cron-job.org can trigger your rules, set a signing secret on the connection. Since cron-job.org sends the same body each time, the signature is fixed. Compute it once:

$secret  = 'your-signing-secret';
$payload = '{"event_type":"custom_event","metadata":{"source":"cron-job.org","label":"nightly-sweep"}}';
echo hash_hmac('sha256', $payload, $secret);

Add a custom header in cron-job.org: x-signature: <computed value>. The body you send must match exactly what you signed – use compact JSON, not pretty-printed.

Note: All webhook POST endpoints return HTTP 200 even when no rules matched. Check the Insight Dashboard to confirm rules are firing.

Verifying scheduled runs

After cron-job.org fires, go to Order Daemon → Insight Dashboard and filter by source webhook. You will see an entry for each trigger, showing which rules matched and what actions ran.