Skip to content

Instantly share code, notes, and snippets.

Last active February 16, 2017 21:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* Script to send a WooCommerce tracking email to the client
* @author: Mike Schoenrock (
// Load the WordPress Environment
// change that to where your wp-blog-header.php is located
require( dirname( __FILE__ ) . '../../../../../wp-blog-header.php' );
// Load the email class
require_once( 'class-email.php' );
// get the order from WooCommerce
$order_id = '12345'; // WooCommerce order_id
$order = new WC_Order($order_id);
$customer_name = $order->get_formatted_billing_full_name();
$customer_email = $order->billing_email;
// tracking number
$tracking_number = '123456789';
// generate and send email
$email = new Tracking_Email();
$body = $email->generate_message($tracking_number, $customer_name);
$content = $email->wrap_message('Your tracking number', $body, ''); // see
$email->send( $customer_email, 'Your tracking number', $content );
// additional, if you want you can add a note to the order that the tracking email was sent
// the thirds parameter (false) tells WC to make this comment not visible to the customer
$order->add_order_note( $order_note, 0, false ); // see
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment