本文整理匯總了PHP中J2Store::email方法的典型用法代碼示例。如果您正苦於以下問題:PHP J2Store::email方法的具體用法?PHP J2Store::email怎麽用?PHP J2Store::email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類J2Store
的用法示例。
在下文中一共展示了J2Store::email方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendVouchers
public function sendVouchers($cids)
{
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$params = J2Store::config();
$sitename = $config->get('sitename');
$emailHelper = J2Store::email();
$mailfrom = $config->get('mailfrom');
$fromname = $config->get('fromname');
$failed = 0;
foreach ($cids as $cid) {
$voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone();
$voucherTable->load($cid);
$mailer = JFactory::getMailer();
$mailer->setSender(array($mailfrom, $fromname));
$mailer->isHtml(true);
$mailer->addRecipient($voucherTable->email_to);
$mailer->setSubject($voucherTable->subject);
// parse inline images before setting the body
$emailHelper->processInlineImages($voucherTable->email_body, $mailer);
$mailer->setBody($voucherTable->email_body);
//Allow plugins to modify
J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer));
if ($mailer->Send() !== true) {
$this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to));
$failed++;
}
J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer));
$mailer = null;
}
if ($failed > 0) {
return false;
}
return true;
}
示例2: _process
/**
*
* @return HTML
*/
function _process()
{
$app = JFactory::getApplication();
$data = $app->input->getArray($_POST);
$error = '';
// prepare some data
$validate_ipn = $this->params->get('validate_ipn', 1);
if ($validate_ipn) {
$custom = $data['custom'];
$custom_array = explode('|', $custom);
$order_id = $custom_array[0];
// load the orderpayment record and set some values
$order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone();
$result = $order->load(array('order_id' => $order_id));
if ($result && !empty($order->order_id) && $order->order_id == $order_id) {
// validate the IPN info
$error = $this->_validateIPN($data, $order);
if (!empty($error)) {
// ipn Validation failed
$data['ipn_validation_results'] = $error;
}
}
}
$data['transaction_details'] = $this->_getFormattedTransactionDetails($data);
$this->_log($data['transaction_details']);
// process the payment based on its type
if (!empty($data['txn_type'])) {
$payment_error = '';
if ($data['txn_type'] == 'cart') {
// Payment received for multiple items; source is Express Checkout or the PayPal Shopping Cart.
$payment_error = $this->_processSale($data, $error);
} else {
// other methods not supported right now
$payment_error = JText::_("J2STORE_PAYPAL_ERROR_INVALID_TRANSACTION_TYPE") . ": " . $data['txn_type'];
}
if ($payment_error) {
// it seems like an error has occurred during the payment process
$error .= $error ? "\n" . $payment_error : $payment_error;
}
}
if ($error) {
$sitename = $config->get('sitename');
//send error notification to the administrators
$subject = JText::sprintf('J2STORE_PAYPAL_EMAIL_PAYMENT_NOT_VALIDATED_SUBJECT', $sitename);
$receivers = $this->_getAdmins();
foreach ($receivers as $receiver) {
$body = JText::sprintf('J2STORE_PAYPAL_EMAIL_PAYMENT_FAILED_BODY', $receiver->name, $sitename, JURI::root(), $error, $data['transaction_details']);
J2Store::email()->sendErrorEmails($receiver->email, $subject, $body);
}
return $error;
}
// if here, all went well
$error = 'processed';
return $error;
}
示例3: notify_customer
public function notify_customer()
{
if (empty($this->order_id)) {
return;
}
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$params = J2Store::config();
$sitename = $config->get('sitename');
$emailHelper = J2Store::email();
$orderinfo = $this->getOrderInformation();
$mailer = $emailHelper->getEmail($this);
J2Store::plugin()->event('BeforeOrderNotification', array($this, &$mailer));
$mailfrom = $config->get('mailfrom');
$fromname = $config->get('fromname');
$mailer->setSender(array($mailfrom, $fromname));
// clone the mailer object so that we can send the same email to the administrators.
$admin_mailer = clone $mailer;
if (isset($this->user_email) && !empty($this->user_email) && $mailer != false) {
$mailer->addRecipient($this->user_email);
try {
if ($mailer->send()) {
$this->add_history(JText::_('J2STORE_CUSTOMER_NOTIFIED'));
J2Store::plugin()->event('AfterOrderNotification', array($this));
}
} catch (Exception $e) {
$this->add_history($e->getMessage());
}
$mailer = null;
}
// send emails to store administrators. Some servers does not like to send BCC. So its better we send the notifications seperately.
$admin_emails = $params->get('admin_email');
$admin_emails = explode(',', $admin_emails);
if (count($admin_emails)) {
$admin_mailer->addRecipient($admin_emails);
try {
if ($admin_mailer->send()) {
$this->add_history(JText::_('J2STORE_ADMINISTRATORS_NOTIFIED'));
}
} catch (Exception $e) {
$this->add_history($e->getMessage());
}
$admin_mailer = null;
}
}
示例4: getTestMail
private function getTestMail($order, $template, $isHTML = 1)
{
$mailer = clone JFactory::getMailer();
$mailer->IsHTML($isHTML);
// Required in order not to get broken characters
$mailer->CharSet = 'UTF-8';
$extras = array();
$subject = $template->subject;
if (isset($template->body_source) && $template->body_source == 'file') {
$templateText = J2Store::email()->getTemplateFromFile($template, $order);
} else {
$templateText = $template->body;
}
$this->loadLanguageOverrides($order);
$templateText = J2Store::email()->processTags($templateText, $order, $extras);
$subject = J2Store::email()->processTags($subject, $order, $extras);
$baseURL = str_replace('/administrator', '', JURI::base());
//replace administrator string, if present
$baseURL = ltrim($baseURL, '/');
$mailer->setSubject($subject);
// Include inline images
$pattern = '/(src)=\\"([^"]*)\\"/i';
$number_of_matches = preg_match_all($pattern, $templateText, $matches, PREG_OFFSET_CAPTURE);
if ($number_of_matches > 0) {
$substitutions = $matches[2];
$last_position = 0;
$temp = '';
// Loop all URLs
$imgidx = 0;
$imageSubs = array();
foreach ($substitutions as &$entry) {
// Copy unchanged part, if it exists
if ($entry[1] > 0) {
$temp .= substr($templateText, $last_position, $entry[1] - $last_position);
}
// Examine the current URL
$url = $entry[0];
if (substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://') {
// External link, skip
$temp .= $url;
} else {
$ext = strtolower(JFile::getExt($url));
if (!JFile::exists($url)) {
// Relative path, make absolute
$url = $baseURL . ltrim($url, '/');
}
if (!JFile::exists($url) || !in_array($ext, array('jpg', 'png', 'gif'))) {
// Not an image or inexistent file
$temp .= $url;
} else {
// Image found, substitute
if (!array_key_exists($url, $imageSubs)) {
// First time I see this image, add as embedded image and push to
// $imageSubs array.
$imgidx++;
$mailer->AddEmbeddedImage($url, 'img' . $imgidx, basename($url));
$imageSubs[$url] = $imgidx;
}
// Do the substitution of the image
$temp .= 'cid:img' . $imageSubs[$url];
}
}
// Calculate next starting offset
$last_position = $entry[1] + strlen($entry[0]);
}
// Do we have any remaining part of the string we have to copy?
if ($last_position < strlen($templateText)) {
$temp .= substr($templateText, $last_position);
}
// Replace content with the processed one
$templateText = $temp;
}
$htmlExtra = '';
$lang = JFactory::getLanguage();
if ($lang->isRTL()) {
$htmlExtra = ' dir="rtl"';
}
$body = '<html' . $htmlExtra . '><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=' . $mailer->CharSet . '">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>';
//echo $body.$templateText; exit;
$mailer->setBody($body . $templateText);
return $mailer;
}
示例5: _evaluateSimplePaymentResponse
/**
* Proceeds the simple payment
*
* @param string $resp
* @param array $submitted_values
* @return object Message object
* @access protected
*/
function _evaluateSimplePaymentResponse($resp, $submitted_values)
{
$object = new JObject();
$object->message = '';
$html = '';
$errors = array();
$return = array();
$user = JFactory::getUser();
$config = J2Store::config();
$transaction_details = $this->_getFormattedTransactionDetails($resp);
$this->_log($transaction_details, 'Payment Gateway Response');
// =======================
// verify & create payment
// =======================
$order_id = $submitted_values['VendorTxCode'];
// check that payment amount is correct for order_id
F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
$orderpayment = F0FTable::getInstance('Order', 'J2StoreTable');
$orderpayment->load(array('order_id' => $order_id));
if ($orderpayment->order_id == $order_id) {
$values = array();
$transaction_id = isset($resp['VPSTxId']) ? $resp['VPSTxId'] : '';
$orderpayment->transaction_details = $transaction_details;
$orderpayment->transaction_id = $transaction_id;
$orderpayment->transaction_status = $resp['Status'];
//set a default status to it
$order_state_id = 4;
// PENDING
if (isset($resp['Status'])) {
switch ($resp['Status']) {
case 'OK':
$order_state_id = 1;
// CONFIRMED
break;
case 'PENDING':
$order_state_id = 4;
break;
case 'NOTAUTHED':
case 'MALFORMED':
case 'INVALID':
case 'REJECTED':
case 'AUTHENTICATED':
case 'REGISTERED':
case 'ERROR':
$order_state_id = 3;
break;
case 'ABORT':
$order_state_id = 5;
break;
}
}
if ($order_state_id == 1) {
$orderpayment->payment_complete();
} else {
$orderpayment->update_status($order_state_id);
}
// save the order
if (!$orderpayment->store()) {
$errors[] = $orderpayment->getError();
} else {
$orderpayment->empty_cart();
}
} else {
$errors[] = JText::_('J2STORE_SAGEPAY_ORDER_ID_MISMATCH');
}
if (empty($errors)) {
$return['success'] = JText::_($this->params->get('onafterpayment', ''));
$return['redirect'] = JRoute::_('index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=' . $this->_element . '&paction=display');
} else {
$error = count($errors) ? implode("\n", $errors) : '';
$sitename = $config->get('sitename');
$subject = JText::sprintf('J2STORE_SAGEPAY_EMAIL_PAYMENT_NOT_VALIDATED_SUBJECT', $sitename);
$recipients = $this->_getAdmins();
foreach ($recipients as $receiver) {
$body = JText::sprintf('J2STORE_SAGEPAY_EMAIL_PAYMENT_FAILED_BODY', $receiver->name, $sitename, JURI::root(), $error, $transaction_details);
J2Store::email()->sendErrorEmails($receiver->email, $subject, $body);
}
$this->_log($error, 'Transaction Errors');
$return['error'] = $error;
}
return $return;
// ===================
// end custom code
// ===================
}
示例6: getFormatedInvoice
public function getFormatedInvoice($order)
{
$text = $this->loadInvoiceTemplate($order);
$template = J2Store::email()->processTags($text, $order, $extras = array());
return $template;
}