Automattic\WooCommerce\Internal\Admin\Orders

ListTable::column_order_date()publicWC 1.0

Renders the order date.

{} Это метод класса: ListTable{}

Хуки из метода

Возвращает

null. Ничего.

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

$ListTable = new ListTable();
$ListTable->column_order_date( $order ): void;
$order(WC_Order) (обязательный)
The order object for the current row.

Код ListTable::column_order_date() WC 6.7.0

public function column_order_date( WC_Order $order ): void {
	$order_timestamp = $order->get_date_created() ? $order->get_date_created()->getTimestamp() : '';

	if ( ! $order_timestamp ) {
		echo '–';
		return;
	}

	// Check if the order was created within the last 24 hours, and not in the future.
	if ( $order_timestamp > strtotime( '-1 day', time() ) && $order_timestamp <= time() ) {
		$show_date = sprintf(
		/* translators: %s: human-readable time difference */
			_x( '%s ago', '%s = human-readable time difference', 'woocommerce' ),
			human_time_diff( $order->get_date_created()->getTimestamp(), time() )
		);
	} else {
		$show_date = $order->get_date_created()->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', 'woocommerce' ) ) );
	}
	printf(
		'<time datetime="%1$s" title="%2$s">%3$s</time>',
		esc_attr( $order->get_date_created()->date( 'c' ) ),
		esc_html( $order->get_date_created()->date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) ),
		esc_html( $show_date )
	);
}