Tweak email
Need export emails sent to customers? Dynamic subject lines? Order details in the body?
Here’s how.
Send export to the customer
By default, exports email to the store owner. This adds the customer too.
|
1 2 3 4 5 6 7 |
//send email to customer add_filter( "woe_export_email_recipients", function($emails){ $order = new WC_Order(WC_Order_Export_Engine::$order_id); $emails[] = $order->get_billing_email(); return $emails; }); |
What it does: Customer receives the same export file as you.
When you need it: Order confirmation PDFs. Digital delivery receipts. Automated packing slips.
Warning: Customers see everything in your export. Filter sensitive columns first.
Add company name to email subject
Use {billing_company} as a tag. It gets replaced automatically.
|
1 2 3 4 5 6 7 |
// support tag {billing_company} in email subject add_filter("woe_export_email_subject",function($subject){ $order = new WC_Order( WC_Order_Export_Engine::$order_id); $subject = str_replace("{billing_company}",$order->get_billing_company(),$subject); return $subject ; }); |
Setup: In your email settings, set subject to Order export for {billing_company}. Code fills in the company name.
Add current date to subject
|
1 2 3 4 5 |
// tag {date_sent} can be used in email subject add_filter("woe_export_email_subject",function($subject){ $date = current_time("d/m/y"); return str_replace("{date_sent}",$date,$subject); }); |
Example subject: Export sent on {date_sent} becomes Export sent on 19/05/26.
Pro tip: Change d/m/y to Y-m-d for international format.
Add order number to filename
|
1 2 3 4 5 6 7 |
// support tag {ordernumber} in filename add_filter('woe_make_filename_replacements', function ($pairs) { $order= new WC_Order( WC_Order_Export_Engine::$order_id); $pairs['{ordernumber}'] = $order->get_order_number(); // tweak it ? return $pairs; }); |
Setup: In filename settings, use export-{ordernumber}.csv. Each export gets a unique name.
Real example: export-1001.csv, export-1002.csv. No more overwriting.
Add previous month and year to filename
|
1 2 3 4 5 6 7 8 |
// tags {prev_mon} and {prev_year} can be used in filename add_filter('woe_make_filename_replacements',function($pairs) { $t = strtotime("previous month"); $pairs['{prev_mon}'] = date('m',$t); $pairs['{prev_year}'] = date('Y',$t); return $pairs; }); |
Setup: Use sales-{prev_mon}-{prev_year}.csv. For May 2026 export, filename becomes sales-04-2026.csv.
Perfect for: Monthly reports. Scheduled exports.
Add order total sum to email
|
1 2 3 4 5 6 7 8 9 10 |
// support tag {sum_of_orders} in email subject/body add_filter( 'woe_make_filename_replacements', function($pairs) { $total = 0; foreach(WC_Order_Export_Engine::$orders_for_export as $pos=>$order_id) { $order = new WC_Order($order_id); $total += $order->get_total(); } $pairs['{sum_of_orders}'] = $total; return $pairs; }); |
Use in: Email subject or body. {sum_of_orders} becomes 1250.00.
When you need it: Daily sales reports. Weekly summaries. Accountant notifications.
Add full order details to email body
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// put order details to email body add_filter( "woe_export_email_message", function($message ){ $order = new WC_Order(WC_Order_Export_Engine::$order_id); $message = ""; $message .= "Order number: " . $order->get_order_number()."nn"; $message .= "Shipping name: " . $order->get_shipping_first_name()." " . $order->get_shipping_last_name()."n"; $message .= "Shipping address: " . $order->get_shipping_address_1().", " . $order->get_shipping_city().", " .$order->get_shipping_postcode()."n"; $message .= "Shipping telephone: " . get_post_meta($order->get_id(),"_shipping_phone",true) ."nn"; foreach($order->get_items() as $item) $message .= "$item[name] x $item[qty]n"; return $message; }); |
What you get: Email contains order summary. No need to open attachment.
Real example:
|
1 2 3 4 5 6 7 8 |
Order number: 1001 Shipping name: John Smith Shipping address: 123 Main St, Los Angeles, 90210 Shipping telephone: 555-1234 Blue Widget x 2 Red Gadget x 1 |
Pro tip: Add more fields. Billing email. Payment method. Order total. Just copy the pattern.
Where to put these snippets
Add to your theme’s functions.php. Use one or combine several.
Advanced Order Export for WooCommerce handles the export. These snippets modify emails before sending.
Common mistake
Using {ordernumber} in filename but not adding the replacement code. The tag stays literal. File saves as export-{ordernumber}.csv.
Always add the corresponding code snippet for each tag.
Pro tip
Combine multiple tags. Subject like Order {ordernumber} for {billing_company} - sent {date_sent}.
Test with a single order first. Verify replacements work. Then run bulk exports.
Real talk
Email tweaks save time. No more manual renaming files. No more “which customer was this for?”
Start with one tag. Add more as needed. Your team will wonder how they lived without it.