/** * Create the email notifications and save to the db. * * @param Cart/ShoppingCart $objCart * @return void * @throws Exception */ public static function emailReceipts($objCart) { if ($objCart instanceof Cart === false && $objCart instanceof ShoppingCart == false) { Yii::log("Invalid Cart Object passed. Emails notifications not created", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); throw new Exception(Yii::t('checkout', 'Error creating email notifications, the cart was not valid.')); } if (_xls_get_conf('EMAIL_SEND_CUSTOMER', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_CUSTOMER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $objEmail->to = $objCart->customer->email; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } if (_xls_get_conf('EMAIL_SEND_STORE', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_OWNER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } }
public function actionEmail() { if (Yii::app()->user->isGuest) { _xls_404(); } $model = new ShareForm(); if (isset($_POST['ShareForm'])) { $model->attributes = $_POST['ShareForm']; if ($model->validate()) { $strCode = $model->code; //Make sure code we've been passed is valid $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode)); if (!$objWishlist->Visible) { _xls_404(); } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id); $model->fromEmail = $objCustomer->email; $model->fromName = $objCustomer->fullname; } $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null); $objEmail = new EmailQueue(); $objEmail->customer_id = $objWishlist->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $objEmail->to = $model->toEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true); } else { $response_array['status'] = 'error'; $response_array['errormsg'] = _xls_convert_errors($model->getErrors()); } echo json_encode($response_array); } }
/** * Create an Email receipt for both the customer and the store, if needed. This goes to our emailqueue table * @param $objCart */ public static function EmailReceipts($objCart) { if (_xls_get_conf('EMAIL_SEND_CUSTOMER', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_CUSTOMER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $objEmail->to = $objCart->customer->email; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } if (_xls_get_conf('EMAIL_SEND_STORE', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_OWNER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } }