as_next_scheduled_action()WC 1.0

Check if there is an existing action in the queue with a given hook, args and group combination.

An action in the queue could be pending, in-progress or async. If the is pending for a time in future, its scheduled date will be returned as a timestamp. If it is currently being run, or an async action sitting in the queue waiting to be processed, in which case boolean true will be returned. Or there may be no async, in-progress or pending action for this hook, in which case, boolean false will be the return value.

Хуков нет.


int|true|false. The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action.


as_next_scheduled_action( $hook, $args, $group );
$hook(строка) (обязательный)
Name of the hook to search for.
Arguments of the action to be searched.
По умолчанию: null
Group of the action to be searched.
По умолчанию: ''

Код as_next_scheduled_action() WC 7.7.2

function as_next_scheduled_action( $hook, $args = null, $group = '' ) {
	if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
		return false;

	$params = array(
		'hook'    => $hook,
		'orderby' => 'date',
		'order'   => 'ASC',
		'group'   => $group,

	if ( is_array( $args ) ) {
		$params['args'] = $args;

	$params['status'] = ActionScheduler_Store::STATUS_RUNNING;
	$action_id        = ActionScheduler::store()->query_action( $params );
	if ( $action_id ) {
		return true;

	$params['status'] = ActionScheduler_Store::STATUS_PENDING;
	$action_id        = ActionScheduler::store()->query_action( $params );
	if ( null === $action_id ) {
		return false;

	$action         = ActionScheduler::store()->fetch_action( $action_id );
	$scheduled_date = $action->get_schedule()->get_date();
	if ( $scheduled_date ) {
		return (int) $scheduled_date->format( 'U' );
	} elseif ( null === $scheduled_date ) { // pending async action with NullSchedule.
		return true;

	return false;