public static function dailySubscriptionEmailReminderCheck()
 {
     Cart66Setting::setValue('daily_subscription_reminders_last_checked', Cart66Common::localTs());
     // Function that fires daily to send out subscription reminder emails.  This will be triggered once a day at 3 AM.
     // If this function fires emails will be sent.
     $dayStart = date('Y-m-d 00:00:00', Cart66Common::localTs());
     $dayEnd = date('Y-m-d 00:00:00', strtotime('+ 1 day', Cart66Common::localTs()));
     $reminder = new Cart66MembershipReminders();
     $reminders = $reminder->getModels();
     foreach ($reminders as $r) {
         if ($r->enable == 1) {
             $interval = explode(',', $r->interval);
             foreach ($interval as $i) {
                 $new_interval = trim($i) . ' ' . $r->interval_unit;
                 $product = new Cart66Product($r->subscription_plan_id);
                 $start = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayStart)));
                 $end = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayEnd)));
                 $sub = new Cart66AccountSubscription();
                 $subs = $sub->getModels("where active_until >= '{$start}' AND active_until < '{$end}' AND lifetime != '1' AND product_id = '{$product->id}'");
                 $log = array();
                 foreach ($subs as $s) {
                     if ($r->validateReminderEmails($s->id)) {
                         $r->sendReminderEmails($s->id);
                         $log[] = $s->id . ' :: ' . $s->billing_first_name . ' ' . $s->billing_last_name;
                     }
                 }
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Start: {$start} :: End: {$end}");
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription ids that meet the criteria: " . print_r($log, true));
             }
         }
     }
 }
예제 #2
0
        }
        ?>
                  </p>
                </th>
                <td></td>
              </tr>
              <tr valign="top">
                <th scope="row"></th>
                <td></td>
              </tr>
            </tbody>
          </table>
        </form>
        <?php 
        $rem = new Cart66MembershipReminders();
        if (count($rem->getModels()) > 0) {
            ?>
          <table class="widefat Cart66HighlightTable" id="subscription_reminders_table">
            <thead>
              <tr>
                <th><?php 
            _e('Subscription', 'cart66');
            ?>
</th>
                <th><?php 
            _e('Active', 'cart66');
            ?>
</th>
                <th><?php 
            _e('Interval', 'cart66');
            ?>