View Categories

Developer Hooks, Filters and URL Reference

Scheduled & Automatic Order Status Controller for WooCommerce exposes filters and actions so you can adjust rule matching, the values used in conditions, and the orders query in code, without editing plugin files. All hooks use the alg_wc_order_status_rules_ prefix. The order status change history is stored in the order meta key _alg_wc_order_status_change_history.

Value and matching filters #

Filter Filtered value Arguments
alg_wc_order_status_rules_do_apply_rule Whether a rule applies to an order (boolean) $result, $order, $rule_id, $args
alg_wc_order_status_rules_order_amount Order amount used in min/max amount checks $amount, $options, $rule_id, $order, $condition_id
alg_wc_order_status_rules_order_quantity Order item count used in min/max quantity checks $quantity, $options, $rule_id, $order
alg_wc_order_status_rules_check_dates_order_date Order date used in the created-before/after checks $date_created, $options, $rule_id, $order

Force a rule to apply (or skip) in code #

add_filter( 'alg_wc_order_status_rules_do_apply_rule', function ( $result, $order, $rule_id, $args ) {
    // Never auto-cancel orders paid with a specific gateway, for rule #1.
    if ( 1 === (int) $rule_id && 'my_gateway' === $order->get_payment_method() ) {
        return false;
    }
    return $result;
}, 10, 4 );

Orders query filters #

These affect periodical processing, URL processing and the “Run all rules now” tool.

  • alg_wc_order_status_rules_wc_get_orders_args – arguments $args, $core. Filters the wc_get_orders() query array (status, orderby, order, type, limit).
  • alg_wc_order_status_rules_wc_get_orders – arguments $order_ids, $core. Filters the resulting list of order IDs before processing.

Options-list filters #

These extend the option choices shown in the Advanced settings. Each is passed its default option array.

  • alg_wc_order_status_rules_hooks – the “Process rules on” choices.
  • alg_wc_order_status_rules_status_change_hooks – the “Save status change on” choices.
  • alg_wc_order_status_rules_status_functions – the “Statuses” source functions.

Priority filters #

  • alg_wc_order_status_rules_hooks_priority – arguments $priority, $hook. Default 10. Sets the priority the rule-processing callback attaches at.
  • alg_wc_order_status_rules_status_change_hooks_priority – arguments $priority, $hook. Default 1. Sets the priority the history-tracking callback attaches at.

Pro / internal filters #

  • alg_wc_order_status_rules_rules_total – arguments $value. The number of rules. The Pro plugin hooks this to allow more than one; on the free plugin it stays at 1.
  • alg_wc_order_status_rules_settings – internal gate used to make the “Total rules” field editable in Pro. Not intended for store customization.

Actions #

Action Fires when Arguments
alg_wc_order_status_rules_before_rule_applied Just before a matching rule changes the status $order, $rule_id, $args, $core
alg_wc_order_status_rules_after_rule_applied Just after a matching rule changes the status $order, $rule_id, $args, $core
alg_wc_order_status_rules_after_save_settings After the plugin settings are saved (none)
alg_wc_order_status_rules_shop_order_screen On the admin order edit screen, when that hook is selected in “Process rules on” $order_id
alg_wc_order_status_rules_shop_subscription_screen On the admin subscription edit screen, when that hook is selected $order_id
alg_wc_order_status_rules_process_rules The scheduled event (WP Cron and Action Scheduler use this) (scheduler args)

Run custom code after a rule changes a status #

add_action( 'alg_wc_order_status_rules_after_rule_applied', function ( $order, $rule_id, $args, $core ) {
    // Notify an external system that order #{$order->get_id()} was updated by rule #{$rule_id}.
}, 10, 4 );

Processing rules via URL #

When Allow rules processing via URL is enabled in the Advanced section, visiting a front-end URL with the alg_wc_order_status_rules_process_rules query parameter processes all rules. This is an alternative to WP Cron when you use a real server cron job.

https://example.com/?alg_wc_order_status_rules_process_rules

Add the optional alg_wc_order_status_rules_process_rules_redirect parameter to redirect after processing:

https://example.com/?alg_wc_order_status_rules_process_rules&alg_wc_order_status_rules_process_rules_redirect=https://example.com/wp-admin/

Note: the URL trigger is not authenticated. Treat it as a semi-public endpoint and avoid exposing it where it could be called repeatedly by untrusted visitors.

Deprecated hook #

The settings-saved action was renamed in version 2.0.0. Use alg_wc_order_status_rules_after_save_settings. The old name alg_wc_order_status_after_save_settings (without rules) no longer fires.

Need help? #

If you are extending Order Status Rules and a hook does not behave as expected, contact our team on the support forum with the hook name and a short code sample.