Skip to content

Architecture

Boot sequence

StatusLogger::get_instance() (via the Module trait) calls init(), which boots four singletons:

Class Role
StatusWatcher Hooks woocommerce_order_status_changed and woocommerce_subscription_status_changed to write log entries
ContextWatcher Hooks renewal actions to tag log entries with a context string (e.g. renewal)
Migrator Runs versioned database migrations on activation
RecurringTasksMigrator Handles recurring background migration tasks (e.g. switching foreign key mode when HPOS is toggled)

HPOS compatibility

The order_id and subscription_id foreign keys in wc_status_log_orders can point to either wp_posts (classic) or wp_wc_orders (HPOS). The current mode is stored in the status_logger_foreign_key option and can be switched at runtime via OrderStatusLog::switch_foreign_key_mode_to_hpos() / switch_foreign_key_mode_to_wp_posts().

The CheckDataStoreConstraints recurring task detects which storage mode WooCommerce is using and triggers the foreign key switch automatically.