/** * Example prepare redSHOP Product method * * Method is called by the product view * * @param object The Product Template Data * @param object The product params * @param object The product object */ public function afterUpdateStock($stockroom_data) { $redshopMail = new redshopMail(); if ($stockroom_data['regular_stock'] || $stockroom_data['preorder_stock']) { $userData = $this->getNotifyUsers($stockroom_data); if (count($userData) > 0) { for ($u = 0; $u < count($userData); $u++) { $productData = $this->getProductData($userData[$u]); $productDetail = $productData['product_detail']; $productName = $productData['product_name']; $notify_template = $redshopMail->getMailtemplate(0, "notify_stock_mail"); if (count($notify_template) > 0) { $message = $notify_template[0]->mail_body; $mail_subject = $notify_template[0]->mail_subject; } else { return; } $message = str_replace("{stocknotify_intro_text}", JText::_('COM_REDSHOP_STOCK_NOTIFY_INTRO_TEXT'), $message); $message = str_replace("{product_detail}", $productDetail, $message); $mail_subject = str_replace("{product_name}", $productName, $mail_subject); if ($userData[$u]->user_email) { JUtility::sendMail(SHOP_NAME, SHOP_NAME, $userData[$u]->user_email, $mail_subject, $message, 1); } $this->deleteNotifiedUsers($userData[$u]); } } } }
public function sendMailForReview($data) { $this->store($data); $producthelper = new producthelper(); $redshopMail = new redshopMail(); $user = JFactory::getUser(); $url = JURI::base(); $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $mailbcc = null; $fromname = $data['username']; $from = $user->email; $subject = ""; $message = $data['title']; $comment = $data['comment']; $username = $data['username']; $product_id = $data['product_id']; $mailbody = $redshopMail->getMailtemplate(0, "review_mail"); $data_add = $message; if (count($mailbody) > 0) { $data_add = $mailbody[0]->mail_body; $subject = $mailbody[0]->mail_subject; if (trim($mailbody[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailbody[0]->mail_bcc); } } $product = $producthelper->getProductById($product_id); $link = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id . '&Itemid=' . $Itemid); $product_url = "<a href=" . $link . ">" . $product->product_name . "</a>"; $data_add = str_replace("{product_link}", $product_url, $data_add); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{title}", $message, $data_add); $data_add = str_replace("{comment}", $comment, $data_add); $data_add = str_replace("{username}", $username, $data_add); if (ADMINISTRATOR_EMAIL != "") { $sendto = explode(",", ADMINISTRATOR_EMAIL); if (JFactory::getMailer()->sendMail($from, $fromname, $sendto, $subject, $data_add, $mode = 1, null, $mailbcc)) { return true; } else { return false; } } }
public function sendProductMailToFriend($your_name, $friend_name, $product_id, $email) { $producthelper = new producthelper(); $redshopMail = new redshopMail(); $url = JURI::base(); $option = JRequest::getVar('option'); $mailinfo = $redshopMail->getMailtemplate(0, "product"); $data_add = ""; $subject = ""; $mailbcc = null; if (count($mailinfo) > 0) { $data_add = $mailinfo[0]->mail_body; $subject = $mailinfo[0]->mail_subject; if (trim($mailinfo[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailinfo[0]->mail_bcc); } } else { $data_add = "<p>Hi {friend_name} ,</p>\r\n<p>New Product : {product_name}</p>\r\n<p>{product_desc} Please check this link : {product_url}</p>\r\n<p> </p>\r\n<p> </p>"; $subject = "Send to friend"; } $data_add = str_replace("{friend_name}", $friend_name, $data_add); $data_add = str_replace("{your_name}", $your_name, $data_add); $product = $producthelper->getProductById($product_id); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{product_desc}", $product->product_desc, $data_add); $rlink = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id); $product_url = "<a href=" . $rlink . ">" . $rlink . "</a>"; $data_add = str_replace("{product_url}", $product_url, $data_add); $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $subject = str_replace("{product_name}", $product->product_name, $subject); $subject = str_replace("{shopname}", SHOP_NAME, $subject); if ($email != "") { if (JFactory::getMailer()->sendMail($from, $fromname, $email, $subject, $data_add, 1, null, $mailbcc)) { echo "<div class='' align='center'>" . JText::_('COM_REDSHOP_EMAIL_HAS_BEEN_SENT_SUCCESSFULLY') . "</div>"; } else { echo "<div class='' align='center'>" . JText::_('COM_REDSHOP_EMAIL_HAS_NOT_BEEN_SENT_SUCCESSFULLY') . "</div>"; } } exit; }
public function sendMailForAskQuestion($data) { $this->store($data); $producthelper = new producthelper(); $redshopMail = new redshopMail(); $url = JURI::base(); $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $mailbcc = null; $fromname = $data['your_name']; $from = $data['your_email']; $subject = ""; $message = $data['your_question']; $product_id = $data['pid']; $mailbody = $redshopMail->getMailtemplate(0, "ask_question_mail"); $data_add = $message; if (count($mailbody) > 0) { $data_add = $mailbody[0]->mail_body; $subject = $mailbody[0]->mail_subject; if (trim($mailbody[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailbody[0]->mail_bcc); } } $product = $producthelper->getProductById($product_id); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{product_desc}", $product->product_desc, $data_add); // Init required properties $data['address'] = isset($data['address']) ? $data['address'] : null; $data['telephone'] = isset($data['telephone']) ? $data['telephone'] : null; $link = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id . '&Itemid=' . $Itemid); $product_url = "<a href=" . $link . ">" . $product->product_name . "</a>"; $data_add = str_replace("{product_link}", $product_url, $data_add); $data_add = str_replace("{user_question}", $message, $data_add); $data_add = str_replace("{answer}", "", $data_add); $subject = str_replace("{user_question}", $message, $subject); $subject = str_replace("{shopname}", SHOP_NAME, $subject); $data_add = str_replace("{user_address}", $data['address'], $data_add); $data_add = str_replace("{user_telephone}", $data['telephone'], $data_add); $data_add = str_replace("{user_telephone_lbl}", JText::_('COM_REDSHOP_USER_PHONE_LBL'), $data_add); $data_add = str_replace("{user_address_lbl}", JText::_('COM_REDSHOP_USER_ADDRESS_LBL'), $data_add); if (ADMINISTRATOR_EMAIL != "") { $sendto = explode(",", ADMINISTRATOR_EMAIL); if (JFactory::getMailer()->sendMail($from, $fromname, $sendto, $subject, $data_add, $mode = 1, null, $mailbcc)) { return true; } else { return false; } } }
/** * Color mail function. * * @return void */ public function color_mail() { $date = JFactory::getDate(); $redshopMail = new redshopMail(); $today = time(); $fdate = $date->toFormat('%Y-%m-%d'); $db = $db = JFactory::getDbo(); $query = "SELECT * FROM #__" . TABLE_PREFIX . "_sample_request where block = 0 "; $db->setQuery($query); $data = $db->loadObjectList(); foreach ($data as $color_detail) { if ($color_detail->reminder_1 == 0) { $send_date = $color_detail->registerdate + COLOUR_SAMPLE_REMAINDER_1 * 60; if ($today >= $send_date) { $bodytmp = ""; $subject = ""; $mailbcc = null; $mail_data = $redshopMail->getMailtemplate(0, 'colour_sample_first_reminder'); if (count($mail_data) > 0) { $mail_data = $mail_data[0]; $bodytmp = $mail_data->mail_body; $subject = $mail_data->mail_subject; if (trim($mail_data->mail_bcc) != "") { $mailbcc = explode(",", $mail_data->mail_bcc); } } $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $recipient = $color_detail->email; $body = str_replace("{name}", $color_detail->name, $bodytmp); $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc); if ($sent == 1) { $q_update = "UPDATE #__" . TABLE_PREFIX . "_sample_request SET reminder_1 = 1 WHERE request_id = " . (int) $color_detail->request_id; $db->setQuery($q_update); $db->query(); } } } if ($color_detail->reminder_2 == 0) { $send_date = date("Y-m-d", $color_detail->registerdate + COLOUR_SAMPLE_REMAINDER_2 * (60 * 60 * 24)); if ($fdate == $send_date) { $bodytmp = ""; $subject = ""; $mailbcc = null; $mail_data = $redshopMail->getMailtemplate(0, 'colour_sample_second_reminder'); if (count($mail_data) > 0) { $mail_data = $mail_data[0]; $bodytmp = $mail_data->mail_body; $subject = $mail_data->mail_subject; if (trim($mail_data->mail_bcc) != "") { $mailbcc = explode(",", $mail_data->mail_bcc); } } $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $recipient = $color_detail->email; $body = str_replace("{name}", $color_detail->name, $bodytmp); $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc); if ($sent == 1) { $q_update = "UPDATE #__" . TABLE_PREFIX . "_sample_request SET reminder_2 = 1 WHERE request_id = " . (int) $color_detail->request_id; $db->setQuery($q_update); $db->query(); } } } if ($color_detail->reminder_3 == 0) { $send_date = date("Y-m-d", $color_detail->registerdate + COLOUR_SAMPLE_REMAINDER_3 * (60 * 60 * 24)); $better_token = md5(uniqid(mt_rand(), true)); $token = substr($better_token, 0, 10); $start_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $end_date = $start_date + COLOUR_COUPON_DURATION * 23 * 59 * 59; if ($fdate == $send_date) { $bodytmp = ""; $subject = ""; $mailbcc = null; $mail_data = $redshopMail->getMailtemplate(0, 'colour_sample_third_reminder'); if (count($mail_data) > 0) { $mail_data = $mail_data[0]; $bodytmp = $mail_data->mail_body; $subject = $mail_data->mail_subject; if (trim($mail_data->mail_bcc) != "") { $mailbcc = explode(",", $mail_data->mail_bcc); } } $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $recipient = $color_detail->email; $body = str_replace("{name}", $color_detail->name, $bodytmp); $body = str_replace("{days}", COLOUR_COUPON_DURATION, $body); $body = str_replace("{discount}", COLOUR_DISCOUNT_PERCENTAGE, $body); $body = str_replace("{coupon_code}", $token, $body); $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc); $sql = "select id FROM #__users where email = " . $db->quote($recipient); $db->setQuery($sql); if ($uid = $db->loadResult()) { $sql = "INSERT INTO #__" . TABLE_PREFIX . "_coupons` (`coupon_code`, `percent_or_total`, `coupon_value`, `start_date`, `end_date`, `coupon_type`, `userid`, `published`)\r\n\t\t\t\t\t\t\t\t\t\tVALUES (" . $db->quote($token) . ", '1', '" . DISCOUNT_PERCENTAGE . "', " . $db->quote($start_date) . ", " . $db->quote($end_date) . ", '1', '" . (int) $uid . "', '1')"; $db->setQuery($sql); $db->query(); } if ($sent == 1) { $q_update = "UPDATE #__" . TABLE_PREFIX . "_sample_request SET reminder_3 = 1 WHERE request_id = " . (int) $color_detail->request_id; $db->setQuery($q_update); $db->query(); } } } else { if ($color_detail->reminder_coupon == 0) { $send_date = date("Y-m-d", $color_detail->registerdate + 4 * (60 * 60 * 24)); $sql = "select id FROM #__users where email = " . $db->quote($color_detail->email); $db->setQuery($sql); $uid = $db->loadResult(); $sql = "select id FROM #__" . TABLE_PREFIX . "_coupons where userid = " . (int) $uid; $db->setQuery($sql); $coupon_code = $db->loadResult(); if ($fdate == $send_date) { $bodytmp = ""; $subject = ""; $mailbcc = null; $mail_data = $redshopMail->getMailtemplate(0, 'colour_sample_third_reminder'); if (count($mail_data) > 0) { $mail_data = $mail_data[0]; $bodytmp = $mail_data->mail_body; $subject = $mail_data->mail_subject; if (trim($mail_data->mail_bcc) != "") { $mailbcc = explode(",", $mail_data->mail_bcc); } } $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $recipient = $color_detail->email; $body = str_replace("{name}", $color_detail->name, $bodytmp); $body = str_replace("{days}", COLOUR_COUPON_DURATION, $body); $body = str_replace("{discount}", COLOUR_DISCOUNT_PERCENTAGE, $body); $body = str_replace("{coupon_code}", $coupon_code, $body); $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc); if ($sent == 1) { $q_update = "UPDATE #__" . TABLE_PREFIX . "_sample_request SET reminder_coupon = 1 WHERE request_id = " . (int) $color_detail->request_id; $db->setQuery($q_update); $db->query(); } } } } } }
public function usercreate($data) { $redshopMail = new redshopMail(); $order_functions = new order_functions(); $Itemid = JRequest::getVar('Itemid'); $app = JFactory::getApplication(); // Get required system objects $user = clone JFactory::getUser(); $pathway = $app->getPathway(); $config = JFactory::getConfig(); $authorize = JFactory::getACL(); $document = JFactory::getDocument(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $SiteName = $app->getCfg('sitename'); $usersConfig = JComponentHelper::getParams('com_users'); $usersConfig->set('allowUserRegistration', 1); if ($usersConfig->get('allowUserRegistration') == '0') { JError::raiseError(403, JText::_('COM_REDSHOP_ACCESS_FORBIDDEN')); return; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 'Registered'; } // Bind the post array to the user object if (!$user->bind(JRequest::get('post'), 'usertype')) { JError::raiseError(500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', 'Registered'); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); $date = JFactory::getDate(); $user->set('registerDate', $date->toMySQL()); $useractivation = $usersConfig->get('useractivation'); if ($useractivation == '1') { JLoader::import('joomla.user.helper'); $user->set('block', '0'); } if ($data['is_company'] == 1) { $tmp = @explode(" ", $data['contact_person']); $name = @$tmp[0] . ' ' . $tmp[1]; $name = JRequest::getVar('username'); } else { $name = JRequest::getVar('firstname') . ' ' . JRequest::getVar('lastname'); } $email = JRequest::getVar('email'); $password = $order_functions->random_gen_enc_key(12); // Disallow control chars in the email $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password); $user->password = md5($password); $user->set('name', $name); $user->name = $name; // If there was an error with registration, set the message and display form if (!$user->save()) { JError::raiseWarning('', JText::_($user->getError())); return false; } $user_id = $user->id; $user->set('id', 0); if ($useractivation == 1) { $message = JText::_('COM_REDSHOP_REG_COMPLETE_ACTIVATE'); } else { $message = JText::_('COM_REDSHOP_REG_COMPLETE'); } // Creating Joomla user end $row = $this->getTable('user_detail'); $row->user_id = $user_id; if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if ($data['is_company'] == 1) { if (SHOPPER_GROUP_DEFAULT_COMPANY != 0) { $row->shopper_group_id = SHOPPER_GROUP_DEFAULT_COMPANY; } else { $row->shopper_group_id = 2; } } else { if (SHOPPER_GROUP_DEFAULT_PRIVATE != 0) { $row->shopper_group_id = SHOPPER_GROUP_DEFAULT_PRIVATE; } else { $row->shopper_group_id = 1; } } if ($data['is_company'] == 1) { $tmp = explode(" ", $data['contact_person']); $row->firstname = $tmp[0]; $row->lastname = $tmp[1]; } $row->user_email = $user->email; $row->address_type = 'BT'; if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $email = $user->email; $quotation_id = $quotationDetail->quotation_id; $quotationdetailurl = JURI::root() . 'index.php?option=com_redshop&view=quotation_detail&quoid=' . $quotation_id . '&encr=' . $quotationDetail->quotation_encrkey; $mailbody = '<table>'; $mailbody .= '<tr><td>' . JText::_('COM_REDSHOP_USERNAME') . '</td><td> : </td><td>' . $data['username'] . '</td></tr>'; $mailbody .= '<tr><td>' . JText::_('COM_REDSHOP_PASSWORD') . '</td><td> : </td><td>' . $password . '</td></tr>'; $mailbody .= '<tr><td>' . JText::_('COM_REDSHOP_QUOTATION_DETAILS') . '</td><td> : </td><td><a href="' . $quotationdetailurl . '">' . JText::_("COM_REDSHOP_QUOTATION_DETAILS") . '</a></td></tr>'; $mailbody .= '</table>'; $mailsubject = 'Register'; $mailbcc = null; $mailinfo = $redshopMail->getMailtemplate(0, "quotation_user_register"); if (count($mailinfo) > 0) { $mailbody = $mailinfo[0]->mail_body; $mailsubject = $mailinfo[0]->mail_subject; if (trim($mailinfo[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailinfo[0]->mail_bcc); } } $producthelper = new producthelper(); $session = JFactory::getSession(); $cart = $session->get('cart'); $user = JFactory::getUser(); $cart['user_id'] = $user_id; $user_data = $producthelper->getUserInformation($user_id); $cart['user_info_id'] = $user_data->users_info_id; $quotationDetail = $this->store($cart); $this->sendQuotationMail($quotationDetail->quotation_id); $link = "<a href='" . $quotationdetailurl . "'>" . JText::_("COM_REDSHOP_QUOTATION_DETAILS") . "</a>"; $mailbody = str_replace('{link}', $link, $mailbody); $mailbody = str_replace('{username}', $name, $mailbody); $mailbody = str_replace('{password}', $name, $mailbody); JFactory::getMailer()->sendMail($MailFrom, $FromName, $email, $mailsubject, $mailbody, 1, null, $mailbcc); $session = JFactory::getSession(); $session->set('cart', null); $session->set('ccdata', null); $session->set('issplit', null); $session->set('userfiled', null); unset($_SESSION['ccdata']); return; }
public function sendWishlist($post) { $user = JFactory::getUser(); $redshopMail = new redshopMail(); $redhelper = new redhelper(); $wishlist_id = JRequest::getInt('wishlist_id'); $emailto = $post['emailto']; $sender = $post['sender']; $email = $post['email']; $subject = $post['subject']; $Itemid = $post['Itemid']; $producthelper = new producthelper(); // Get data from database if not than fetch from session if ($user->id && $wishlist_id) { $query = "SELECT DISTINCT w.* ,p.* FROM " . $this->_table_prefix . "wishlist AS w " . "LEFT JOIN " . $this->_table_prefix . "wishlist_product AS pw ON w.wishlist_id=pw.wishlist_id " . "LEFT JOIN " . $this->_table_prefix . "product AS p ON p.product_id = pw.product_id " . "WHERE w.user_id = " . (int) $user->id . " " . "AND w.wishlist_id = " . (int) $wishlist_id . " "; } else { // Add this code to send wishlist while user is not loged in ... $prod_id = ""; for ($add_i = 1; $add_i < $_SESSION["no_of_prod"]; $add_i++) { $prod_id .= (int) $_SESSION['wish_' . $add_i]->product_id . ","; } $prod_id .= (int) $_SESSION['wish_' . $add_i]->product_id; $query = "SELECT DISTINCT p.* FROM " . $this->_table_prefix . "product AS p " . "WHERE p.product_id IN (" . $prod_id . ")"; } $MyWishlist = $this->_getList($query); $i = 0; $data = ""; $mailbcc = null; $wishlist_body = $redshopMail->getMailtemplate(0, "mywishlist_mail"); if (count($wishlist_body) > 0) { $wishlist_body = $wishlist_body[0]; $data = $wishlist_body->mail_body; $subject = $wishlist_body->mail_subject; if (trim($wishlist_body->mail_bcc) != "") { $mailbcc = explode(",", $wishlist_body->mail_bcc); } } if ($data) { $template_d1 = explode("{product_loop_start}", $data); $template_d2 = explode("{product_loop_end}", $template_d1[1]); $wishlist_desc = $template_d2[0]; if (strstr($data, '{product_thumb_image_2}')) { $tag = '{product_thumb_image_2}'; $h_thumb = THUMB_HEIGHT_2; $w_thumb = THUMB_WIDTH_2; } elseif (strstr($data, '{product_thumb_image_3}')) { $tag = '{product_thumb_image_3}'; $h_thumb = THUMB_HEIGHT_3; $w_thumb = THUMB_WIDTH_3; } elseif (strstr($data, '{product_thumb_image_1}')) { $tag = '{product_thumb_image_1}'; $h_thumb = THUMB_HEIGHT; $w_thumb = THUMB_WIDTH; } else { $tag = '{product_thumb_image}'; $h_thumb = THUMB_HEIGHT; $w_thumb = THUMB_WIDTH; } $temp_template = ''; if (count($MyWishlist)) { foreach ($MyWishlist as $row) { $Itemid = $redhelper->getItemid($row->product_id); $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $row->product_id . '&Itemid=' . (int) $Itemid, true, -1); $thum_image = $producthelper->getProductImage($row->product_id, $link, $w_thumb, $h_thumb); $pname = $row->product_name; $pname = $pname; $wishlist_data = str_replace($tag, $thum_image, $wishlist_desc); $wishlist_data = str_replace('{product_name}', $pname, $wishlist_data); // Attribute ajax change if (!$row->not_for_sale) { $wishlist_data = $producthelper->GetProductShowPrice($row->product_id, $wishlist_data); } else { $wishlist_data = str_replace("{product_price}", "", $wishlist_data); $wishlist_data = str_replace("{price_excluding_vat}", "", $wishlist_data); $wishlist_data = str_replace("{product_price_table}", "", $wishlist_data); $wishlist_data = str_replace("{product_old_price}", "", $wishlist_data); $wishlist_data = str_replace("{product_price_saving}", "", $wishlist_data); } $temp_template .= $wishlist_data; } } $data = $template_d1[0] . $temp_template . $template_d2[1]; $name = @explode('@', $emailto); $data = str_replace('{from}', $sender, $data); $data = str_replace('{name}', $name[0], $data); $data = str_replace('{from_name}', $sender, $data); $data_add = $data; } else { if (count($MyWishlist)) { $link = JURI::root() . "index.php?tmpl=component&option=com_redshop&view=account&layout=mywishlist&mail=1"; foreach ($MyWishlist as $row) { $data_add .= '<div class="redProductWishlist">'; $thum_image = ""; $pname = $row->product_name; $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $row->product_id . '&Itemid=' . $Itemid); $thum_image = $producthelper->getProductImage($row->product_id, $link, THUMB_WIDTH, THUMB_HEIGHT); $data_add .= $thum_image; $pname = "<div><a href='" . $link . "' >" . $pname . "</a></div>"; $data_add .= $pname; $formatted_price = $producthelper->GetProductShowPrice($row->product_id, $wishlist_data); // For attribute price count $price_add = '<span id="pr_price">' . $formatted_price . '</span>'; $i++; $data_add .= '</div>'; } } } if (JFactory::getMailer()->sendMail($email, $sender, $emailto, $subject, $data_add, true, null, $mailbcc)) { return true; } else { return false; } }
public function changeOrderStatusMail($order_id, $newstatus, $order_comment = '') { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $config = new Redconfiguration(); $carthelper = new rsCarthelper(); $order_functions = new order_functions(); $redshopMail = new redshopMail(); $shippinghelper = new shipping(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $mailbcc = null; $mailtemplate = $redshopMail->getMailtemplate(0, '', 'mail_section LIKE "order_status" AND mail_order_status LIKE ' . $db->quote($newstatus) . ' '); if (count($mailtemplate) > 0) { $maildata = $mailtemplate[0]->mail_body; $mailsubject = $mailtemplate[0]->mail_subject; if (trim($mailtemplate[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailtemplate[0]->mail_bcc); } // Getting the order details $orderdetail = $this->getOrderDetails($order_id); $barcode_code = $orderdetail->barcode; // Changes to parse all tags same as order mail start $row = $order_functions->getOrderDetails($order_id); $maildata = str_replace("{order_mail_intro_text_title}", JText::_('COM_REDSHOP_ORDER_MAIL_INTRO_TEXT_TITLE'), $maildata); $maildata = str_replace("{order_mail_intro_text}", JText::_('COM_REDSHOP_ORDER_MAIL_INTRO_TEXT'), $maildata); $maildata = $carthelper->replaceOrderTemplate($row, $maildata); $arr_discount_type = array(); $arr_discount = explode('@', $row->discount_type); $discount_type = ''; for ($d = 0; $d < count($arr_discount); $d++) { if ($arr_discount[$d]) { $arr_discount_type = explode(':', $arr_discount[$d]); if ($arr_discount_type[0] == 'c') { $discount_type .= JText::_('COM_REDSHOP_COUPON_CODE') . ' : ' . $arr_discount_type[1] . '<br>'; } if ($arr_discount_type[0] == 'v') { $discount_type .= JText::_('COM_REDSHOP_VOUCHER_CODE') . ' : ' . $arr_discount_type[1] . '<br>'; } } } if (!$discount_type) { $discount_type = JText::_('COM_REDSHOP_NO_DISCOUNT_AVAILABLE'); } $search[] = "{discount_type}"; $replace[] = $discount_type; $maildata = str_replace($search_sub, $replace_sub, $maildata); // Changes to parse all tags same as order mail end $userdetail = $this->getOrderBillingUserInfo($order_id); // For barcode if (strstr($maildata, "{barcode}")) { if ($barcode_code != "" && file_exists(REDSHOP_FRONT_IMAGES_RELPATH . "barcode/" . $barcode_code . ".png")) { $barcode_code = $barcode_code; } else { $barcode_code = $this->barcode_randon_number(12, 1); $this->updatebarcode($order_id, $barcode_code); } $img_url = REDSHOP_FRONT_IMAGES_ABSPATH . "barcode/" . $barcode_code . ".png"; $bar_replace = '<img alt="" src="' . $img_url . '">'; $search[] = "{barcode}"; $replace[] = $bar_replace; } // Getting the order status changed template from mail center end $maildata = $carthelper->replaceBillingAddress($maildata, $userdetail); // Get ShippingAddress From order Users info $shippingaddresses = $this->getOrderShippingUserInfo($order_id); if (count($shippingaddresses) <= 0) { $shippingaddresses = $userdetail; } $maildata = $carthelper->replaceShippingAddress($maildata, $shippingaddresses); $search[] = "{shopname}"; $replace[] = SHOP_NAME; $search[] = "{fullname}"; $replace[] = $userdetail->firstname . " " . $userdetail->lastname; $search[] = "{customer_id}"; $replace[] = $userdetail->users_info_id; $search[] = "{order_id}"; $replace[] = $order_id; $search[] = "{order_number}"; $replace[] = $orderdetail->order_number; $search[] = "{order_date}"; $replace[] = $config->convertDateFormat($orderdetail->cdate); $search[] = "{customer_note_lbl}"; $replace[] = JText::_('COM_REDSHOP_COMMENT'); $search[] = "{customer_note}"; $replace[] = $order_comment; $search[] = "{order_detail_link_lbl}"; $replace[] = JText::_('COM_REDSHOP_ORDER_DETAIL_LBL'); $orderdetailurl = JURI::root() . 'index.php?option=com_redshop&view=order_detail&oid=' . $order_id . '&encr=' . $orderdetail->encr_key; $search[] = "{order_detail_link}"; $replace[] = "<a href='" . $orderdetailurl . "'>" . JText::_("COM_REDSHOP_ORDER_DETAIL_LINK_LBL") . "</a>"; $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $orderdetail->ship_method_id))); if (count($details) <= 1) { $details = explode("|", $orderdetail->ship_method_id); } $shopLocation = $orderdetail->shop_id; if ($details[0] != 'plgredshop_shippingdefault_shipping_GLS') { $shopLocation = ''; } $arrLocationDetails = explode('|', $shopLocation); $orderdetail->track_no = $arrLocationDetails[0]; $search[] = "{order_track_no}"; $replace[] = trim($orderdetail->track_no); $order_trackURL = 'http://www.pacsoftonline.com/ext.po.dk.dk.track?key=' . POSTDK_CUSTOMER_NO . '&order=' . $order_id; $search[] = "{order_track_url}"; $replace[] = "<a href='" . $order_trackURL . "'>" . JText::_("COM_REDSHOP_TRACK_LINK_LBL") . "</a>"; $mailbody = str_replace($search, $replace, $maildata); $mailsubject = str_replace($search, $replace, $mailsubject); if ($userdetail->user_email != '' && $mailbody) { JUtility::sendMail($MailFrom, $FromName, $userdetail->user_email, $mailsubject, $mailbody, 1, null, $mailbcc); } } }