From 105c3fa8639893813a1997b6feafa027632fb91c Mon Sep 17 00:00:00 2001 From: Thomas Sjolshagen Date: Thu, 15 Nov 2018 12:45:47 -0700 Subject: [PATCH] BUG FIX: No need to send out credit card expiration warning for non-recurring users --- class/class.handle-messages.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/class/class.handle-messages.php b/class/class.handle-messages.php index ca1ccf2..2214d56 100644 --- a/class/class.handle-messages.php +++ b/class/class.handle-messages.php @@ -112,13 +112,14 @@ protected function task( $message ) { $uses_recurring = $message->get_user()->has_active_subscription(); $next_payment = $message->get_user()->get_next_payment(); $has_enddate = $message->get_user()->get_end_of_membership_date(); - $type = $reminder_notice->get_type_from_string( 'ccexpiring' ); - $is_creditcard = ( $template_type == $type ); + $is_creditcard = ( $template_type == $reminder_notice->get_type_from_string( 'ccexpiring' ) ); - $util->log( "Processing for a credit card template ({$template_type} vs {$type})? " . ( $is_creditcard ? 'Yes' : 'No' ) ); - - if ( true === $is_creditcard ) { - $util->log( "Credit Card expiration warning" ); + /** + * @since v4.4 - BUG FIX: No need to send out credit card expiration warning for non-recurring users + */ + $util->log( "Processing for a credit card expiration message template? " . ( $is_creditcard ? 'Yes' : 'No' ) ); + if ( true === $is_creditcard && true === $uses_recurring ) { + $util->log( "Credit Card expiration warning for recurring members only" ); $check_date = $reminder_notice->end_of_month() . " 23:59:59"; } @@ -309,10 +310,10 @@ private function send_admin_notice() { if ( true === wp_mail( $admin_address, $subject, $body, $headers ) ) { $already_sent[ $this->type ] = $today; - $log_length = intval( apply_filters( 'e20r-payment-warning-admin-notice-log-days', 30 ) ); + $log_length = intval( apply_filters( 'e20r-payment-warning-admin-notice-log-days', 30 ) ); if ( $log_length < 0 ) { - $utils->log("Filter provided invalid log length value: [{$log_length}]!"); + $utils->log( "Filter provided invalid log length value: [{$log_length}]!" ); $log_length = 30; } @@ -320,7 +321,7 @@ private function send_admin_notice() { if ( count( $users ) >= $log_length ) { sort( $users ); - $preserve = array_slice( $users, -$log_length, null, true ); + $preserve = array_slice( $users, - $log_length, null, true ); $utils->log( "Preserving " . count( $preserve ) . " days worth of send logs" ); // Save the log @@ -333,6 +334,6 @@ private function send_admin_notice() { return true; } - + }