Automattic\WooCommerce\Internal\Admin\Schedulers

OrdersScheduler::init │ public static │ WC 1.0

Attach order lookup update hooks.

Method of the class: OrdersScheduler{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = OrdersScheduler::init();

OrdersScheduler::init() code WC 11.1.2

public static function init() {
	// Activate WC_Order extension.
	\Automattic\WooCommerce\Admin\Overrides\Order::add_filters();
	\Automattic\WooCommerce\Admin\Overrides\OrderRefund::add_filters();

	if ( self::is_scheduled_import_enabled() ) {
		// Schedule recurring batch processor.
		add_action( 'action_scheduler_ensure_recurring_actions', array( __CLASS__, 'schedule_recurring_batch_processor' ) );
	} else {
		// Schedule import immediately on order create/update/delete.
		add_action( 'woocommerce_update_order', array( __CLASS__, 'possibly_schedule_import' ) );
		add_filter( 'woocommerce_create_order', array( __CLASS__, 'possibly_schedule_import' ) );
		add_action( 'woocommerce_refund_created', array( __CLASS__, 'possibly_schedule_import' ) );
		add_action( 'woocommerce_schedule_import', array( __CLASS__, 'possibly_schedule_import' ) );

		// Trash and untrash bypass woocommerce_update_order. CPT emits both the Woo
		// and the post hooks for one operation, so each handler takes a single store.
		add_action( 'woocommerce_trash_order', array( __CLASS__, 'maybe_schedule_import_on_trash' ) );
		add_action( 'woocommerce_order_status_changed', array( __CLASS__, 'maybe_schedule_import_on_untrash' ), 10, 2 );
		add_action( 'trashed_post', array( __CLASS__, 'maybe_schedule_import_on_post_trash_change' ) );
		add_action( 'untrashed_post', array( __CLASS__, 'maybe_schedule_import_on_post_trash_change' ) );
	}

	// Watch for changes to the scheduled import option.
	add_action( 'add_option_' . self::SCHEDULED_IMPORT_OPTION, array( __CLASS__, 'handle_scheduled_import_option_added' ), 10, 2 );
	add_action( 'update_option_' . self::SCHEDULED_IMPORT_OPTION, array( __CLASS__, 'handle_scheduled_import_option_change' ), 10, 2 );
	add_action( 'delete_option', array( __CLASS__, 'handle_scheduled_import_option_before_delete' ), 10, 1 );

	OrdersStatsDataStore::init();
	CouponsDataStore::init();
	ProductsDataStore::init();
	TaxesDataStore::init();
	OrderDataStore::init();

	parent::init();
}