Automattic\WooCommerce\Internal\Admin\Orders

ListTable::render_order_status_column()publicWC 1.0

Renders the order status.

Method of the class: ListTable{}

No Hooks.

Return

null. Nothing.

Usage

$ListTable = new ListTable();
$ListTable->render_order_status_column( $order ): void;
$order(WC_Order) (required)
The order object for the current row.

ListTable::render_order_status_column() code WC 7.1.0

public function render_order_status_column( WC_Order $order ): void {
	$tooltip                 = '';
	$comment_count           = get_comment_count( $order->get_id() );
	$approved_comments_count = absint( $comment_count['approved'] );

	if ( $approved_comments_count ) {
		$latest_notes = wc_get_order_notes(
			array(
				'order_id' => $order->get_id(),
				'limit'    => 1,
				'orderby'  => 'date_created_gmt',
			)
		);

		$latest_note = current( $latest_notes );

		if ( isset( $latest_note->content ) && 1 === $approved_comments_count ) {
			$tooltip = wc_sanitize_tooltip( $latest_note->content );
		} elseif ( isset( $latest_note->content ) ) {
			/* translators: %d: notes count */
			$tooltip = wc_sanitize_tooltip( $latest_note->content . '<br/><small style="display:block">' . sprintf( _n( 'Plus %d other note', 'Plus %d other notes', ( $approved_comments_count - 1 ), 'woocommerce' ), $approved_comments_count - 1 ) . '</small>' );
		} else {
			/* translators: %d: notes count */
			$tooltip = wc_sanitize_tooltip( sprintf( _n( '%d note', '%d notes', $approved_comments_count, 'woocommerce' ), $approved_comments_count ) );
		}
	}

	// Gracefully handle legacy statuses.
	if ( in_array( $order->get_status(), array( 'trash', 'draft' ), true ) ) {
		$status_name = ( get_post_status_object( $order->get_status() ) )->label;
	} else {
		$status_name = wc_get_order_status_name( $order->get_status() );
	}

	if ( $tooltip ) {
		printf( '<mark class="order-status %s tips" data-tip="%s"><span>%s</span></mark>', esc_attr( sanitize_html_class( 'status-' . $order->get_status() ) ), wp_kses_post( $tooltip ), esc_html( $status_name ) );
	} else {
		printf( '<mark class="order-status %s"><span>%s</span></mark>', esc_attr( sanitize_html_class( 'status-' . $order->get_status() ) ), esc_html( $status_name ) );
	}
}