Skip to main content

Extending Ninjalytics

Ninjalytics supports the following filter hooks to allow other plugins and code to extend its functionality. Additionally, platform-specific hooks may also be supported by the corresponding Ninjalytics reporting engine.

ninjalytics_get_order_report_query​

Filters the SQL used to retrieve data for the report from the database.

ArgumentDescription
$queryThe SQL.

ninjalytics_row_value​

Filters the value of an individual report cell or data point.

ArgumentDescription
$rowValueThe value.
$fieldThe field ID.

ninjalytics_addon_fields Pro​

Register custom fields that can be included in reports.

ArgumentDescription
$fieldsThe array of all addon fields.

Functions hooked to ninjalytics_addon_fields must add their fields to the array in the following format:

my_addon_field_id => array(
'label' => 'My Addon Field',
'cb' => my_callback_function
);

where my_callback_function takes the following arguments:

ArgumentDescription
$productThe row data object returned by $wc_report->get_order_report_data(), or the product ID for zero-sales products.
$typenull for regular products, 'shipping' for shipping items, or 'nil' for zero-sales products.
$nilVariationIdFor zero-sales products only, the ID of the product variation if the current row is for a product variation. Otherwise null.

and returns the field value to include in the report for the given row.