Created
May 8, 2018 14:40
-
-
Save mateusneves/cf865858cab4db3e5e6e63c39069c1c7 to your computer and use it in GitHub Desktop.
Woocommerce fail order send email
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 | |
/* | |
* Woocommerce send email to customer when order status is change to Failed | |
*/ | |
add_action( 'woocommerce_order_status_failed', 'mysite_failed'); | |
function mysite_failed($order_id) { | |
error_log("$order_id set to FAILED", 0); | |
$order = wc_get_order( $order_id ); | |
// User data | |
$user_email = $order->get_billing_email(); | |
// From data | |
$email = '[email protected]'; | |
$message = 'Fail order!'; | |
// To data | |
$to = $user_email; | |
$subject = "Fail Order"; | |
$headers = 'From: '. $email . "\r\n" . | |
'Reply-To: ' . $email . "\r\n"; | |
// Send email | |
$sent = wp_mail($to, $subject, strip_tags($message), $headers); | |
if($sent){ | |
}// Message send | |
else { | |
}// Message not send | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment