Automattic\WooCommerce\Internal\Admin\Orders

ListTable::render_order_number_column()publicWC 1.0

Renders the order number, customer name and provides a preview link.

Method of the class: ListTable{}

Hooks from the method

Return

null. Nothing.

Usage

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

ListTable::render_order_number_column() code WC 7.1.0

public function render_order_number_column( WC_Order $order ): void {
	$buyer = '';

	if ( $order->get_billing_first_name() || $order->get_billing_last_name() ) {
		/* translators: 1: first name 2: last name */
		$buyer = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $order->get_billing_first_name(), $order->get_billing_last_name() ) );
	} elseif ( $order->get_billing_company() ) {
		$buyer = trim( $order->get_billing_company() );
	} elseif ( $order->get_customer_id() ) {
		$user  = get_user_by( 'id', $order->get_customer_id() );
		$buyer = ucwords( $user->display_name );
	}

	/**
	 * Filter buyer name in list table orders.
	 *
	 * @since 3.7.0
	 *
	 * @param string   $buyer Buyer name.
	 * @param WC_Order $order Order data.
	 */
	$buyer = apply_filters( 'woocommerce_admin_order_buyer_name', $buyer, $order );

	if ( $order->get_status() === 'trash' ) {
		echo '<strong>#' . esc_attr( $order->get_order_number() ) . ' ' . esc_html( $buyer ) . '</strong>';
	} else {
		echo '<a href="#" class="order-preview" data-order-id="' . absint( $order->get_id() ) . '" title="' . esc_attr( __( 'Preview', 'woocommerce' ) ) . '">' . esc_html( __( 'Preview', 'woocommerce' ) ) . '</a>';
		echo '<a href="' . esc_url( $this->get_order_edit_link( $order ) ) . '" class="order-view"><strong>#' . esc_attr( $order->get_order_number() ) . ' ' . esc_html( $buyer ) . '</strong></a>';
	}
}