原本在woocommerce取消訂單取失敗訂單都只會發郵件通知網站管理員

如果希望客戶也收到訂單失敗的郵件的話

只要在function.php放入以下代碼即可

//Woocommerce 訂單取消或失敗發信通知客戶
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();
}
最後修改日期: 2021 年 11 月 26 日

作者