description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Script to send a WooCommerce tracking email to the client | |
* @author: Mike Schoenrock (ms@halloecho.de) | |
*/ | |
// 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 https://docs.woocommerce.com/wc-apidocs/class-WC_Email.html | |
$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 https://docs.woocommerce.com/wc-apidocs/source-class-WC_Abstract_Order.html#2306-2344 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment