Automattic\WooCommerce\Internal\Admin\Schedulers

OrdersScheduler::maybe_schedule_import_on_untrash │ public static │ WC 11.1.0

Driven off the status transition rather than woocommerce_untrash_order, which fires before the restored status is saved — so an import running synchronously would record wc-trash, and nothing corrects it because the data store suppresses woocommerce_update_order for trash transitions.

CPT reaches this via its own save, so it is handled by untrashed_post instead.

Method of the class: OrdersScheduler{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = OrdersScheduler::maybe_schedule_import_on_untrash( $order_id, $from_status ): void;
$order_id(int) (required)
Order ID.
$from_status(string) (required)
Status the order transitioned from.

Changelog

Since 11.1.0 Introduced.

OrdersScheduler::maybe_schedule_import_on_untrash() code WC 11.1.2

public static function maybe_schedule_import_on_untrash( $order_id, $from_status ): void {
	if ( OrderStatus::TRASH !== $from_status ) {
		return;
	}

	if ( ! OrderUtil::custom_orders_table_usage_is_enabled() ) {
		return;
	}

	self::possibly_schedule_import( $order_id );
}