Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Last active November 13, 2019 22:28
Show Gist options
  • Save NickGreen/2683cba869e1ef1cbfbda17979e9e906 to your computer and use it in GitHub Desktop.
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.
<?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;
}
@NickGreen
Copy link
Author

Note: you'd need to remove the first line if you only want this to run for the order completed email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment