WooCommerce Code Reference

ReportExporter
in package
Uses SchedulerTraits

ReportExporter Class.

Table of Contents

DOWNLOAD_EXPORT_ACTION  = 'woocommerce_admin_download_report_csv'
Export file download action.
EXPORT_STATUS_OPTION  = 'woocommerce_admin_report_export_status'
Export status option name.
$group  : string|null
Action scheduler group.
$name  : string
Slug to identify the scheduler.
$queue  : WC_Queue_Interface
Queue instance.
clear_queued_actions()  : mixed
Clears all queued actions.
do_action_or_reschedule()  : mixed
Check for blocking jobs and reschedule if any exist.
download_export_file()  : mixed
Serve the export file.
email_report_download_link()  : void
Process a report export email action.
export_report()  : void
Process a report export action.
flatten_args()  : string
Flatten multidimensional arrays to store for scheduling.
get_action()  : string|null
Get an action tag name from the action name.
get_actions()  : mixed
Get all available scheduling actions.
get_batch_size()  : int
Returns the batch size for an action.
get_batch_sizes()  : mixed
Batch action size.
get_default_scheduler_actions()  : mixed
Gets the default scheduler actions for batching and scheduling actions.
get_dependencies()  : array<string|int, mixed>
Add action dependencies.
get_dependency()  : string|null
Get dependencies associated with an action.
get_export_percentage_complete()  : bool|int
Get the completion percentage of a report export.
get_next_action_time()  : DateTime|null
Get the DateTime for the next scheduled time an action should run.
get_next_blocking_job()  : false|ActionScheduler_Action
Get the next blocking job for an action.
get_scheduler_actions()  : array<string|int, mixed>
Get all available scheduling actions.
has_existing_jobs()  : bool
Check if existing jobs exist for an action and arguments.
init()  : mixed
Hook in action methods.
queue()  : WC_Queue_Interface
Get queue instance.
queue_batches()  : void
Queue a large number of batch jobs, respecting the batch size limit.
queue_report_export()  : int
Queue up actions for a full report export.
schedule_action()  : mixed
Schedule an action to run and check for dependencies.
set_queue()  : mixed
Set queue instance.
update_export_percentage_complete()  : void
Update the completion percentage of a report export.
get_status_key()  : string
Generate a key to reference an export status.

Constants

DOWNLOAD_EXPORT_ACTION

Export file download action.

public mixed DOWNLOAD_EXPORT_ACTION = 'woocommerce_admin_download_report_csv'

EXPORT_STATUS_OPTION

Export status option name.

public mixed EXPORT_STATUS_OPTION = 'woocommerce_admin_report_export_status'

Properties

Methods

download_export_file()

Serve the export file.

public static download_export_file() : mixed
Return values
mixed

Process a report export email action.

public static email_report_download_link(int $user_id, string $export_id, string $report_type) : void
Parameters
$user_id : int

User ID that requested the email.

$export_id : string

Unique ID for report (timestamp expected).

$report_type : string

Report type. E.g. 'customers'.

Return values
void

export_report()

Process a report export action.

public static export_report(int $page_number, string $export_id, string $report_type, array<string|int, mixed> $report_args) : void
Parameters
$page_number : int

Page number for this action.

$export_id : string

Unique ID for report (timestamp expected).

$report_type : string

Report type. E.g. 'customers'.

$report_args : array<string|int, mixed>

Report parameters, passed to data query.

Return values
void

flatten_args()

Flatten multidimensional arrays to store for scheduling.

public static flatten_args(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>

Argument array.

Return values
string

get_action()

Get an action tag name from the action name.

public static get_action(string $action_name) : string|null
Parameters
$action_name : string

The action name.

Return values
string|null

get_actions()

Get all available scheduling actions.

public static get_actions() : mixed

Used to determine action hook names and clear events.

Return values
mixed

get_batch_size()

Returns the batch size for an action.

public static get_batch_size(string $action) : int
Parameters
$action : string

Single batch action name.

Return values
intBatch size.

get_default_scheduler_actions()

Gets the default scheduler actions for batching and scheduling actions.

public static get_default_scheduler_actions() : mixed
Return values
mixed

get_dependencies()

Add action dependencies.

public static get_dependencies() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_dependency()

Get dependencies associated with an action.

public static get_dependency(string $action_name) : string|null
Parameters
$action_name : string

The action slug.

Return values
string|null

get_export_percentage_complete()

Get the completion percentage of a report export.

public static get_export_percentage_complete(string $report_type, string $export_id) : bool|int
Parameters
$report_type : string

Report type. E.g. 'customers'.

$export_id : string

Unique ID for report (timestamp expected).

Return values
bool|intCompletion percentage, or false if export not found.

get_next_action_time()

Get the DateTime for the next scheduled time an action should run.

public static get_next_action_time(ActionScheduler_Action $action) : DateTime|null

This function allows backwards compatibility with Action Scheduler < v3.0.

Parameters
$action : ActionScheduler_Action

Action.

Return values
DateTime|null

get_next_blocking_job()

Get the next blocking job for an action.

public static get_next_blocking_job(string $action_name) : false|ActionScheduler_Action
Parameters
$action_name : string

Action name.

Return values
false|ActionScheduler_Action

get_scheduler_actions()

Get all available scheduling actions.

public static get_scheduler_actions() : array<string|int, mixed>

Used to determine action hook names and clear events.

Return values
array<string|int, mixed>

has_existing_jobs()

Check if existing jobs exist for an action and arguments.

public static has_existing_jobs(string $action_name, array<string|int, mixed> $args) : bool
Parameters
$action_name : string

Action name.

$args : array<string|int, mixed>

Array of arguments to pass to action.

Return values
bool

queue_batches()

Queue a large number of batch jobs, respecting the batch size limit.

public static queue_batches(int $range_start, int $range_end, string $single_batch_action[, array<string|int, mixed> $action_args = array() ]) : void

Reduces a range of batches down to "single batch" jobs.

Parameters
$range_start : int

Starting batch number.

$range_end : int

Ending batch number.

$single_batch_action : string

Action to schedule for a single batch.

$action_args : array<string|int, mixed> = array()

Action arguments.

Return values
void

queue_report_export()

Queue up actions for a full report export.

public static queue_report_export(string $export_id, string $report_type[, array<string|int, mixed> $report_args = array() ][, bool $send_email = false ]) : int
Parameters
$export_id : string

Unique ID for report (timestamp expected).

$report_type : string

Report type. E.g. 'customers'.

$report_args : array<string|int, mixed> = array()

Report parameters, passed to data query.

$send_email : bool = false

Optional. Send an email when the export is complete.

Return values
intNumber of items to export.

schedule_action()

Schedule an action to run and check for dependencies.

public static schedule_action(string $action_name[, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$action_name : string

Action name.

$args : array<string|int, mixed> = array()

Array of arguments to pass to action.

Return values
mixed

set_queue()

Set queue instance.

public static set_queue(WC_Queue_Interface $queue) : mixed
Parameters
$queue : WC_Queue_Interface

Queue instance.

Return values
mixed

update_export_percentage_complete()

Update the completion percentage of a report export.

public static update_export_percentage_complete(string $report_type, string $export_id, int $percentage) : void
Parameters
$report_type : string

Report type. E.g. 'customers'.

$export_id : string

Unique ID for report (timestamp expected).

$percentage : int

Completion percentage.

Return values
void

get_status_key()

Generate a key to reference an export status.

protected static get_status_key(string $report_type, string $export_id) : string
Parameters
$report_type : string

Report type. E.g. 'customers'.

$export_id : string

Unique ID for report (timestamp expected).

Return values
stringStatus key.