the total events may match the number wanted so these need to be with
equal. removed the equal on the first part.
$event_count = 0;
do {
$event_count = $this->getEventCountForWeekRange( ++$weeks_to_check, $memberId );
- } while ( $event_count <= $total_events_wanted && $total_current_events > $total_events_wanted );
+ } while ( $event_count < $total_events_wanted && $total_current_events >= $total_events_wanted );
$week_string = ( $weeks_to_check === 1 ) ? 'weeks': 'week';
$toDate = date('m/d/Y', strtotime( '+ ' . $weeks_to_check . ' ' . $week_string ));