Tweak email
1 2 3 4 5 6 |
//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; }); |
1 2 3 4 5 6 |
// 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 ; }); |
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); }); |
1 2 3 4 5 6 |
// 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; }); |
1 2 3 4 5 6 7 |
// 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; }); |
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; }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// 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()."\n\n"; $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) ."\n\n"; foreach($order->get_items() as $item) $message .= "$item[name] x $item[qty]\n"; return $message; }); |