Last active
November 13, 2019 22:28
-
-
Save NickGreen/2683cba869e1ef1cbfbda17979e9e906 to your computer and use it in GitHub Desktop.
Don't send customer the default order emails if purchasing a subscription product.
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_filter( 'woocommerce_email_recipient_customer_processing_order', 'wcs_disable_customer_order_email_if_sub', 10, 2 ); | |
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'wcs_disable_customer_order_email_if_sub', 10, 2 ); | |
// If order contains subscription we change the email recipient to "" | |
function wcs_disable_customer_order_email_if_sub( $recipient, $order ) { | |
$page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : ''; | |
if ( 'wc-settings' === $page ) { | |
return $recipient; | |
} | |
if( wcs_order_contains_subscription( $order ) ) $recipient = ''; | |
return $recipient; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: you'd need to remove the first line if you only want this to run for the order completed email.