Automattic\WooCommerce\Admin

ReportExporter::queue_report_export │ public static │ WC 1.0

Queue up actions for a full report export.

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

Хуков нет.

Возвращает

int. Number of items to export.

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

$result = ReportExporter::queue_report_export( $export_id, $report_type, $report_args, $send_email );
$export_id(строка) (обязательный)
Unique ID for report (timestamp expected).
$report_type(строка) (обязательный)
Report type. E.g. 'customers'.
$report_args(массив)
Report parameters, passed to data query.
По умолчанию: array()
$send_email(true|false)
Send an email when the export is complete.
По умолчанию: false

Код ReportExporter::queue_report_export() WC 11.3.0

public static function queue_report_export( $export_id, $report_type, $report_args = array(), $send_email = false ) {
	$exporter = new ReportCSVExporter( $report_type, $report_args );
	$exporter->prepare_data_to_export();

	$total_rows  = $exporter->get_total_rows();
	$batch_size  = $exporter->get_limit();
	$num_batches = (int) ceil( $total_rows / $batch_size );

	if ( 0 < $num_batches ) {
		// An export queued outside a user session has no user to email, but a filter on the email's recipient can still name one.
		$email_user_id = $send_email ? get_current_user_id() : false;

		// Only the first page is queued. Each page queues the next one, so the pages run one at a time and in order.
		self::schedule_action( 'export_report', array( 1, $export_id, $report_type, $report_args, $email_user_id, $num_batches ) );
	}

	return $total_rows;
}