Deep Insights for WooCommerce includes filters for developers. Add them in a small custom plugin or your theme’s functions.php.
Filters
| Filter | Purpose |
|---|---|
deep_insights_view_capability | Capability needed to view reports. Default view_woocommerce_reports. |
deep_insights_manage_capability | Capability needed for settings, imports and customer-level exports. Default manage_woocommerce. |
deep_insights_order_types | Order types to import. Default shop_order. |
deep_insights_import_time_limit | Seconds each background import job may run. Default 20. |
deep_insights_cost_providers | Add a cost-of-goods source. |
deep_insights_shipping_cost_providers | Add a carrier shipping cost source. |
deep_insights_reports | Register extra report classes. |
deep_insights_update_checks | Return false to stop update checks against wpruby.com. |
Deep Insights also respects WooCommerce’s woocommerce_analytics_is_test_order filter.
Example: let editors view reports
add_filter( 'deep_insights_view_capability', function () {
return 'edit_others_posts';
} );
Example: add a cost-of-goods source
If your product costs come from another plugin, implement the CostProvider interface. Return the recorded cost of an order line, or null when it is unknown. Never return an estimate.
use DeepInsights\Integrations\Costs\CostProvider;
class My_Cost_Provider implements CostProvider {
public function id() { return 'my_costs'; }
public function label() { return 'My cost plugin'; }
public function is_available() { return class_exists( 'My_Cost_Plugin' ); }
public function get_line_cost( \WC_Order_Item_Product $item, \WC_Abstract_Order $order ) {
$value = $item->get_meta( '_my_line_cost', true );
return '' === $value ? null : (float) $value;
}
}
add_filter( 'deep_insights_cost_providers', function ( $providers ) {
array_unshift( $providers, new My_Cost_Provider() );
return $providers;
} );
Costs are read when an order syncs. After adding a provider, run Settings → Data → Rebuild from order history to bring in costs for past orders.
Example: carrier shipping costs
Implement DeepInsights\Integrations\Shipping\ShippingCostProvider and register it with deep_insights_shipping_cost_providers. Its get_costs( array $order_ids ) method returns [ order_id => [ 'cost' => float, 'carrier' => string ] ], and is_estimate() says whether the costs are estimates. Estimated costs are labelled as such in the Shipping report.
REST API
The dashboard uses the deep-insights/v1 REST namespace with WordPress cookie authentication. Routes include /reports/{report}, /export/{report}, /status, /options and /settings. Each route checks the capabilities above.