I'm trying to disable a number of WC Subscriptions emails (so they don't get sent). I know that I can do this in the admin settings area manually however I'm trying to do this via PHP (in a plugin). The reason for this is so that when it's moved from the test site to the live site the relevant files can be simply copied across and it's good to go without any manual settings changes.
As an example - removing the new renewal order that gets sent to the site admin.
add_action( 'woocommerce_email', 'SA_unhook_unneeded_emails' );
function SA_unhook_unneeded_emails( $email_class ) {
//remove new_renewal_order email (sent to admin)
remove_action( 'woocommerce_order_status_pending_to_processing_renewal_notification', array( $this, 'trigger' ) );
remove_action( 'woocommerce_order_status_pending_to_completed_renewal_notification', array( $this, 'trigger' ) );
remove_action( 'woocommerce_order_status_pending_to_on-hold_renewal_notification', array( $this, 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_processing_renewal_notification', array( $this, 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_completed_renewal_notification', array( $this, 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_on-hold_renewal_notification', array( $this, 'trigger' ) );
//remove_action( 'woocommerce_order_status_completed_renewal_notification', array( $this, 'trigger' ) );
}
Uncommenting the last remove_action makes no difference. The emails are still sent. I've tried changing woocommerce_email
to wp_head
to see if made any difference but none whatsoever.
There seems to be little documentation (at least that I can find) on the WC subscriptions hooks so I'm struggling to work out what exactly I need to do to get this working.
Any help would be appreciated.