Automattic\WooCommerce\Admin

ReportExporter::queue_report_export()public staticWC 1.0

Queue up actions for a full report export.

Method of the class: ReportExporter{}

No Hooks.

Return

Int. Number of items to export.

Usage

$result = ReportExporter::queue_report_export( $export_id, $report_type, $report_args, $send_email );
$export_id(string) (required)
Unique ID for report (timestamp expected).
$report_type(string) (required)
Report type. E.g. 'customers'.
$report_args(array)
Report parameters, passed to data query.
Default: array()
$send_email(true|false)
Send an email when the export is complete.
Default: false

ReportExporter::queue_report_export() code WC 8.7.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 );

	// Create batches, like initial import.
	$report_batch_args = array( $export_id, $report_type, $report_args );

	if ( 0 < $num_batches ) {
		self::queue_batches( 1, $num_batches, 'export_report', $report_batch_args );

		if ( $send_email ) {
			$email_action_args = array( get_current_user_id(), $export_id, $report_type );
			self::schedule_action( 'email_report_download_link', $email_action_args );
		}
	}

	return $total_rows;
}