ActionScheduler_DBStore::get_date_gmt()protectedWC 1.0

Get the GMT schedule date for an action.

Метод класса: ActionScheduler_DBStore{}

Хуков нет.

Возвращает

\DateTime. The GMT date the action is scheduled to run, or the date that it ran.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_date_gmt( $action_id );
$action_id(int) (обязательный)
Action ID.

Код ActionScheduler_DBStore::get_date_gmt() WC 8.7.0

protected function get_date_gmt( $action_id ) {
	/** @var \wpdb $wpdb */
	global $wpdb;
	$record = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->actionscheduler_actions} WHERE action_id=%d", $action_id ) );
	if ( empty( $record ) ) {
		throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'woocommerce' ), $action_id ) ); //phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
	}
	if ( self::STATUS_PENDING === $record->status ) {
		return as_get_datetime_object( $record->scheduled_date_gmt );
	} else {
		return as_get_datetime_object( $record->last_attempt_gmt );
	}
}