Skip to content

Commit

Permalink
BUG FIX: No need to send out credit card expiration warning for non-r…
Browse files Browse the repository at this point in the history
…ecurring users
  • Loading branch information
sjolshagen committed Nov 15, 2018
1 parent 02fe922 commit 105c3fa
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions class/class.handle-messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -309,18 +310,18 @@ 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;
}

// Maintain user send info for message type option
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
Expand All @@ -333,6 +334,6 @@ private function send_admin_notice() {

return true;
}

}

0 comments on commit 105c3fa

Please sign in to comment.