WC_Report_Downloads::output_report()publicWC 1.0

Output the report.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WC_Report_Downloads = new WC_Report_Downloads();
$WC_Report_Downloads->output_report();

Код WC_Report_Downloads::output_report() WC 8.7.0

public function output_report() {

	$this->prepare_items();

	// Subtitle for permission if set.
	if ( ! empty( $_GET['permission_id'] ) ) { // WPCS: input var ok.
		$permission_id = absint( $_GET['permission_id'] ); // WPCS: input var ok.

		// Load the permission, order, etc. so we can render more information.
		$permission = null;
		$product    = null;

		try {
			$permission = new WC_Customer_Download( $permission_id );
			$product    = wc_get_product( $permission->product_id );
		} catch ( Exception $e ) {
			wp_die( sprintf( esc_html__( 'Permission #%d not found.', 'woocommerce' ), esc_html( $permission_id ) ) );
		}
	}

	echo '<h1>' . esc_html__( 'Customer downloads', 'woocommerce' );

	$filters      = $this->get_filter_vars();
	$filter_list  = array();
	$filter_names = array(
		'product_id'      => __( 'Product', 'woocommerce' ),
		'download_id'     => __( 'File ID', 'woocommerce' ),
		'permission_id'   => __( 'Permission ID', 'woocommerce' ),
		'order_id'        => __( 'Order', 'woocommerce' ),
		'user_id'         => __( 'User', 'woocommerce' ),
		'user_ip_address' => __( 'IP address', 'woocommerce' ),
	);

	foreach ( $filters as $key => $value ) {
		if ( is_null( $value ) ) {
			continue;
		}
		switch ( $key ) {
			case 'order_id':
				$order = wc_get_order( $value );
				if ( $order ) {
					$display_value = _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number();
				} else {
					break 2;
				}
				break;
			case 'product_id':
				$product = wc_get_product( $value );
				if ( $product ) {
					$display_value = $product->get_formatted_name();
				} else {
					break 2;
				}
				break;
			default:
				$display_value = $value;
				break;
		}
		$filter_list[] = $filter_names[ $key ] . ' ' . $display_value . ' <a href="' . esc_url( remove_query_arg( $key ) ) . '" class="woocommerce-reports-remove-filter">&times;</a>';
	}

	echo '</h1>';

	echo '<div id="active-filters" class="woocommerce-reports-wide"><h2>';
	echo esc_html__( 'Active filters', 'woocommerce' ) . ': ';
	echo $filter_list ? wp_kses_post( implode( ', ', $filter_list ) ) : '';
	echo '</h2></div>';

	echo '<div id="poststuff" class="woocommerce-reports-wide">';
	$this->display();
	echo '</div>';
}