Email Reports is built to be extended. You can add your own columns to the report tables, and insert your own content into the email above or below the report.
Put your code in a site-specific plugin or your child theme’s functions.php — not in the Email Reports plugin itself, or the next update will overwrite it.
Custom columns
Several report tables accept extra columns. Each has a pair of filters — one for the header row, one for the body cells — and you need both, or the table will be misaligned. Every one of them receives an array and must return it.
| Filter | Arguments | What it does |
|---|---|---|
sre_order_details_table_header | $th_array | Adds header cells to the order details table. |
sre_order_details_table_content | $array, $order | Adds the matching body cells for each order row. $order is the WC_Order object. |
sre_top_selling_products_details_table_header | $th_array | Adds header cells to the top selling products table. |
sre_top_selling_products_details_table_content | $array, $top_seller, $product_id | Adds the matching body cells for each product row. |
sre_refunded_order_details_table_header | $th_array | Adds header cells to the refund details table. |
sre_top_selling_variations_details_table_content | $array, … | Adds body cells to the top selling variations table. |
Worked examples:
Adding content to the email
These are actions — echo your output rather than returning it.
| Action | Fires | Arguments |
|---|---|---|
before_email_report | After the email header, before the report totals. | $date_range |
after_email_report | At the end of the report, before the footer. | $date_range |
sre_view_after_report_details | After the detail tables, before the end of the report. | $data, $date_range, $previous_date_range |
$date_range carries the period the report covers, so your content can reflect the same dates as the figures above it.
add_action( 'before_email_report', 'my_report_intro', 10, 1 );
function my_report_intro( $date_range ) {
echo '<p style="margin:0 0 16px;">Prepared for the finance team.</p>';
}
These print directly into the email, so echo email-safe HTML — inline styles, tables for layout, no external stylesheets.