From 6259ee69e9eda90ed096b2ce0edb4c0f1767a64a Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 18 Apr 2017 11:35:37 +0100 Subject: [PATCH] Adds a fallback to queue_transactional_email if background sending is disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #14476 After turning off deferred emails by default it seems Subscriptions was using the ‘default’ value in a filter to check if deferred emails were enabled or not to hook in these methods. https://github.com/woocommerce/woocommerce-subscriptions/blob/f87a11cdf0 9bb59aa66f4e86d37592f74193937f/includes/class-wc-subscriptions-email.php #L339 @thenbrent This code change adds a fallback so if this method was hooked in anywhere, and the background emailer was not init or disabled, it will fallback to regular send-now. --- includes/class-wc-emails.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/class-wc-emails.php b/includes/class-wc-emails.php index 99f2873b6f4..dbb642dbbc9 100644 --- a/includes/class-wc-emails.php +++ b/includes/class-wc-emails.php @@ -102,13 +102,18 @@ class WC_Emails { } /** - * Queue transactional email so it's not sent in current request. + * Queues transactional email so it's not sent in current request if enabled, + * otherwise falls back to send now. */ public static function queue_transactional_email() { - self::$background_emailer->push_to_queue( array( - 'filter' => current_filter(), - 'args' => func_get_args(), - ) ); + if ( is_a( self::$background_emailer, 'WC_Background_Emailer' ) ) { + self::$background_emailer->push_to_queue( array( + 'filter' => current_filter(), + 'args' => func_get_args(), + ) ); + } else { + call_user_func_array( array( __CLASS__, 'send_transactional_email' ), func_get_args() ); + } } /**