Created
March 14, 2016 07:48
-
-
Save full-stack-king/fbc887c3432a6f746cc3 to your computer and use it in GitHub Desktop.
WooCommerce failed order email notification
This file contains hidden or 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 | |
/** | |
* Add a failed order email notification | |
*/ | |
function sp_failed_order_email_notification( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
$to = get_option( 'admin_email' ); | |
$subject = 'A order failed, action required'; | |
$message = sprintf( __( '%1$s went to the `failed` order status. This may require action to follow up.', 'text-domain' ), '<a class="link" href="' . admin_url( 'post.php?post=' . $order_id . '&action=edit' ). '">' . sprintf( __( 'Order #%s', 'woocommerce'), $order->get_order_number() ) . '</a>' ); | |
$headers[] = 'From: Me Myself <[email protected]>'; | |
$headers[] = 'Cc: Some Name <[email protected]>'; // Possible CC | |
$headers[] = 'Content-Type: text/html;'; | |
$headers[] = 'charset=UTF-8'; | |
wp_mail( $to, $subject, $message, $headers ); | |
} | |
add_action( 'woocommerce_order_status_failed', 'sp_failed_order_email_notification' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment