Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nczz/762b2454ee51c8c141c37e3689f35c2f to your computer and use it in GitHub Desktop.
Save nczz/762b2454ee51c8c141c37e3689f35c2f to your computer and use it in GitHub Desktop.
[WordPress] WooCommerce 訂單取消或失敗發信通知客戶
<?php
//https://stackoverflow.com/questions/51635878/send-cancelled-and-failed-order-email-to-customer-in-woocommerce-3
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
add_filter( 'woocommerce_email_recipient_failed_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
function wc_cancelled_order_add_customer_email( $recipient, $order ){
// Avoiding errors in backend (mandatory when using $order argument)
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
return $recipient .= "," . $order->get_billing_email();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment