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));
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Delete the account and all account subscriptions assoicated with this account
  */
 public function deleteMe()
 {
     if ($this->id > 0) {
         $sub = new Cart66AccountSubscription();
         $subs = $sub->getModels("where account_id={$this->id}");
         foreach ($subs as $s) {
             $s->deleteMe();
         }
         parent::deleteMe();
     }
 }