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.
| Argument | Description |
|---|---|
$query | The SQL. |
ninjalytics_row_value
Filters the value of an individual report cell or data point.
| Argument | Description |
|---|---|
$rowValue | The value. |
$field | The field ID. |
ninjalytics_addon_fields Pro
Register custom fields that can be included in reports.
| Argument | Description |
|---|---|
$fields | The 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:
| Argument | Description |
|---|---|
$product | The row data object returned by $wc_report->get_order_report_data(), or the product ID for zero-sales products. |
$type | null for regular products, 'shipping' for shipping items, or 'nil' for zero-sales products. |
$nilVariationId | For 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.