Automattic\WooCommerce\Internal\OrderReviews

Scheduler::handle_cancellationpublicWC 1.0

Cancel any pending review-request action and clear the scheduled-at meta.

Hooked directly into woocommerce_trash_order woocommerce_before_delete_order the trash/delete lifecycle events, and called from handle_status_changed() for every status transition out of an eligible status (cancelled, refunded, processing, on-hold, pending, failed, custom statuses…).

Method of the class: Scheduler{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Scheduler = new Scheduler();
$Scheduler->handle_cancellation( $order_id ): void;
$order_id(int) (required)
The affected order ID.

Scheduler::handle_cancellation() code WC 10.9.4

public function handle_cancellation( int $order_id ): void {
	// Always attempt to unschedule, even when the order or meta is missing,
	// so an out-of-sync meta value cannot leave a stray scheduled send.
	// `as_unschedule_action()` is a no-op when no matching action exists.
	as_unschedule_action( self::ACTION_HOOK, array( $order_id ) );

	$order = wc_get_order( $order_id );
	if ( $order instanceof WC_Order && $order->get_meta( self::SCHEDULED_META_KEY ) ) {
		$order->delete_meta_data( self::SCHEDULED_META_KEY );
		$order->save();
	}
}