public function checkFulfillmentSettings($orderId) { $order = new Cart66Order($orderId); $data = array(); foreach ($order->getItems() as $item) { $data[] = $item->product_id; } $orderFulfillment = new Cart66OrderFulfillment(); $orderF = $orderFulfillment->getModels(); $notify = new Cart66AdvancedNotifications($orderId); foreach ($orderF as $of) { $products = array_filter(explode(',', $of->products)); if (array_intersect($data, $products) || empty($products)) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] THEY INTERSECT!"); $notify->sendOrderFulfillmentEmails($of->id); } } }
public function section_notifications_settings() { $tab = 'notifications-email_receipt_settings'; $data = array('tab' => $tab); if (CART66_PRO) { $reminder = new Cart66MembershipReminders(); $orderFulfillment = new Cart66OrderFulfillment(); $errorMessage = ''; $successMessage = ''; if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($_POST['cart66-action'] == 'email log settings') { foreach ($_POST['emailLog'] as $key => $value) { Cart66Setting::setValue($key, $value); } $tab = 'notifications-email_log_settings'; } if ($_POST['cart66-action'] == 'save reminder') { try { $reminder->load($_POST['reminder']['id']); $reminder->setData($_POST['reminder']); $reminder->save(); $reminder->clear(); } catch (Cart66Exception $e) { $errorCode = $e->getCode(); // Reminder save failed if ($errorCode == 66302) { $errors = $reminder->getErrors(); $exception = Cart66Exception::exceptionMessages($e->getCode(), __("The reminder could not be saved for the following reasons", "cart66"), $errors); $errorMessage = Cart66Common::getView('views/error-messages.php', $exception); } } $tab = 'notifications-reminder_settings'; } if ($_POST['cart66-action'] == 'save order fulfillment') { try { $orderFulfillment->load($_POST['fulfillment']['id']); $orderFulfillment->setData($_POST['fulfillment']); $orderFulfillment->save(); $orderFulfillment->clear(); } catch (Cart66Exception $e) { $errorCode = $e->getCode(); if ($errorCode == 66303) { $errors = $orderFulfillment->getErrors(); $exception = Cart66Exception::exceptionMessages($e->getCode(), __("The order fulfillment could not be saved for the following reasons", "cart66"), $errors); $errorMessage = Cart66Common::getView('views/error-messages.php', $exception); } } $tab = 'notifications-fulfillment_settings'; } if ($_POST['cart66-action'] == 'advanced notifications') { Cart66Setting::setValue('enable_advanced_notifications', $_POST['enable_advanced_notifications']); $successMessage = __('Your notification settings have been saved.', 'cart66'); $tab = 'notifications-advanced_notifications'; } } elseif ($_SERVER['REQUEST_METHOD'] == "GET") { if (isset($_GET['task']) && $_GET['task'] == 'edit_reminder' && isset($_GET['id']) && $_GET['id'] > 0) { $id = Cart66Common::getVal('id'); $reminder->load($id); $tab = 'notifications-reminder_settings'; } elseif (isset($_GET['task']) && $_GET['task'] == 'delete_reminder' && isset($_GET['id']) && $_GET['id'] > 0) { $id = Cart66Common::getVal('id'); $reminder->load($id); $reminder->deleteMe(); $reminder->clear(); $tab = 'notifications-reminder_settings'; } elseif (isset($_GET['task']) && $_GET['task'] == 'cancel_reminder') { $tab = 'notifications-reminder_settings'; } elseif (isset($_GET['task']) && $_GET['task'] == 'edit_fulfillment' && isset($_GET['id']) && $_GET['id'] > 0) { $id = Cart66Common::getVal('id'); $orderFulfillment->load($id); $tab = 'notifications-fulfillment_settings'; } elseif (isset($_GET['task']) && $_GET['task'] == 'delete_fulfillment' && isset($_GET['id']) && $_GET['id'] > 0) { $id = Cart66Common::getVal('id'); $orderFulfillment->load($id); $orderFulfillment->deleteMe(); $orderFulfillment->clear(); $tab = 'notifications-fulfillment_settings'; } elseif (isset($_GET['task']) && $_GET['task'] == 'cancel_fulfillment') { $tab = 'notifications-fulfillment_settings'; } } $data = array('reminder' => $reminder, 'order_fulfillment' => $orderFulfillment, 'tab' => $tab, 'error_message' => $errorMessage, 'success_message' => $successMessage); } echo Cart66Common::getView('admin/settings/notifications.php', $data, false); }
public function sendAdvancedEmailReceipts($firstTime = true) { $isSent = false; $subject = $this->parseReceiptShortcodes(Cart66Setting::getValue('receipt_subject'), $this->_order->id, null, 'receipt'); $from_email = Cart66Setting::getValue('receipt_from_address'); $from_name = Cart66Setting::getValue('receipt_from_name'); $head = $this->buildEmailHeader($from_name, $from_email); $email_data = array('from_email' => $from_email, 'from_name' => $from_name, 'to_email' => $this->_order->email, 'to_name' => $this->_order->bill_first_name . ' ' . $this->_order->bill_last_name, 'copy_to' => Cart66Setting::getValue('receipt_copy'), 'head' => $head, 'subject' => $subject, 'msg' => $this->getAdvancedEmailMessage($this->_order, $head['mime']), 'msg_cc' => $this->getAdvancedEmailMessage($this->_order, $head['mime'], 'cc'), 'attachments' => null, 'order_id' => $this->_order->id, 'email_type' => 'RECEIPT', 'log' => 'email_receipts', 'status' => ''); if ($this->_order) { $isSent = $this->sendEmail($email_data); if ($firstTime == true) { $orderFulfillment = new Cart66OrderFulfillment(); $orderFulfillment->checkFulfillmentSettings($this->_order->id); } } return $isSent; }