ActionScheduler_wcSystemStatus::get_action_status_date()protectedWC 1.0

Get oldest or newest scheduled date for a given status.

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

Хуков нет.

Возвращает

DateTime.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_action_status_date( $status, $date_type );
$status(строка) (обязательный)
Action status label/name string.
$date_type(строка)
Oldest or Newest.
По умолчанию: 'oldest'

Код ActionScheduler_wcSystemStatus::get_action_status_date() WC 8.7.0

protected function get_action_status_date( $status, $date_type = 'oldest' ) {

	$order = 'oldest' === $date_type ? 'ASC' : 'DESC';

	$action = $this->store->query_actions(
		array(
			'claimed'  => false,
			'status'   => $status,
			'per_page' => 1,
			'order'    => $order,
		)
	);

	if ( ! empty( $action ) ) {
		$date_object = $this->store->get_date( $action[0] );
		$action_date = $date_object->format( 'Y-m-d H:i:s O' );
	} else {
		$action_date = '–';
	}

	return $action_date;
}