public static function dailyFollowupEmailCheck() { if (Cart66Setting::getValue('enable_followup_emails') == '1') { Cart66Setting::setValue('daily_followup_last_checked', Cart66Common::localTs()); // Function that fires daily to send out followup 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())); $total = Cart66Setting::getValue('followup_email_number') . ' ' . Cart66Setting::getValue('followup_email_time'); $start = date('Y-m-d H:i:s', strtotime('- ' . $total, strtotime($dayStart))); $end = date('Y-m-d H:i:s', strtotime('- ' . $total, strtotime($dayEnd))); $order = new Cart66Order(); $orders = $order->getModels("where ordered_on >= '{$start}' AND ordered_on < '{$end}'"); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Start: {$start} :: End: {$end}"); foreach ($orders as $o) { Cart66AdvancedNotifications::sendFollowupEmail($o->id); } } }