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.

Arguments:

  • $query: The SQL

ninjalytics_row_value

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

Arguments:

  • $rowValue: The value
  • $field: The field ID

ninjalytics_addon_fields Pro

Register custom fields that can be included in reports.

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:

  • $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.

Arguments:

  • $fields: The array of all addon fields.