Skip to content

Instantly share code, notes, and snippets.

@twoelevenjay
Created July 20, 2014 21:48
Show Gist options
  • Save twoelevenjay/657720679664e9651199 to your computer and use it in GitHub Desktop.
Save twoelevenjay/657720679664e9651199 to your computer and use it in GitHub Desktop.
Function to have WooCommerce send an automatic heads up email to the shop owner for orders that switch to a status of on-hold.
add_action('woocommerce_order_status_changed', 'send_hold_email');
function send_hold_email($order_id) {
$order_data = new WC_Order($order_id);
if ($order_data->status=='on-hold') {
global $woocommerce;
$mailer = $woocommerce->mailer();
$message = $mailer->wrap_message(
__( 'Order placed On-hold', 'woocommerce' ),
sprintf( __( 'Order %s has been marked as on-hold. Reason: %s', 'woocommerce' ), $order_data->get_order_number(), $posted['reason_code'] )
);
$mailer->send( get_option( 'admin_email' ), sprintf( __( 'Order %s placed On-hold', 'woocommerce' ), $order_data->get_order_number() ), $message );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment