Jump to content
scottyb

Newsletter products, HTML email

Recommended Posts

Hi

I can't seem to do this update, Sorry.

My products query looks like this:

 

$products_query = "select pd.products_id, p.short_desc, pd.products_name, p.products_price, p.products_tax_class_id, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = 1 and pd.products_id = p.products_id and p.products_status = '1'";

 

I cant find where to put:

'specials_price' => $product['specials_price'], to your $this->productsInfo[] object.

Is it in the admin/includes/modules/newsletter/newsletter_products.php?

or in /admin/newletter.php?

 

oops... previous code is from v2.0, sorry

 

Try this, add

if(s.status, s.specials_new_products_price, NULL) as specials_price

to your sql for your $images_query.

 

then add to $html_content variable inside the if($col > COLS-1) statement

$html_content .= (!empty($images['specials_price'])) ? '<s>' . $images['specials_price'] . '</s>' : '';

 

this should be all you need to include the price in the email. you can also add products_price to $images_query to include in your message.

Share this post


Link to post
Share on other sites

Hi

I used your answer and did it a little different:

if(s.status, s.specials_new_products_price, p.products_price) as products_price,

and used left join.

 

I dont get normal look where the old price is striked out, but it workes.

 

But...

 

somehow the prices will not calculate correct.

It rounds up to the nearest whole.

 

I use this code to get the price:

$currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])

 

Anyone knows why

Edited by melhaa

Share this post


Link to post
Share on other sites
Hi

I used your answer and did it a little different:

if(s.status, s.specials_new_products_price, p.products_price) as products_price,

and used left join.

 

I dont get normal look where the old price is striked out, but it workes.

 

But...

 

somehow the prices will not calculate correct.

It rounds up to the nearest whole.

 

I use this code to get the price:

$currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])

 

Anyone knows why

 

Did you add products_tax_class_id to your sql query?

Share this post


Link to post
Share on other sites

Hi scottyb,

 

great work, excellent contribution, easy to install.

 

For me it is more practical to create template off-line in real html editor (Dreamweaver, Frontpage., etc., etc) than to use small-windowed WYSIWYG/HTML online editor. However I will try to install some of those editor too (like TinyMCE) just to see how they behave together with your contribution.

 

I especially like that there is install version of your contribution for clean install of oscommerce so that it can be "packed" all together.

 

I had only one problem with triple images, but after I found this forum everything was easily resloved.

 

Looking forward for your new version!!!

 

Regards,

 

Nenad


Regards,

 

Nenad

Share this post


Link to post
Share on other sites

Just added or tried to admin - Not seeing any screen from adnin section after clicking newsletter mgr.

<?php

/*

$Id: newsletters.php,v 1.17 2003/06/29 22:50:52 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

if (tep_not_null($action)) {

switch ($action) {

case 'lock':

case 'unlock':

$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

$status = (($action == 'lock') ? '1' : '0');

 

tep_db_query("update " . TABLE_NEWSLETTERS . " set locked = '" . $status . "' where newsletters_id = '" . (int)$newsletter_id . "'");

 

tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));

break;

case 'insert':

case 'update':

if (isset($HTTP_POST_VARS['newsletter_id'])) $newsletter_id = tep_db_prepare_input($HTTP_POST_VARS['newsletter_id']);

$newsletter_module = tep_db_prepare_input($HTTP_POST_VARS['module']);

$title = tep_db_prepare_input($HTTP_POST_VARS['title']);

$content = tep_db_prepare_input($HTTP_POST_VARS['content']);

$products = $HTTP_POST_VARS['chosen'];

 

$newsletter_error = false;

if (empty($title)) {

$messageStack->add(ERROR_NEWSLETTER_TITLE, 'error');

$newsletter_error = true;

}

 

if (empty($module)) {

$messageStack->add(ERROR_NEWSLETTER_MODULE, 'error');

$newsletter_error = true;

}

 

if ($newsletter_error == false) {

//newsletter products

$products_string = '';

$once = false;

if(!empty($products)){

for($i=0, $n=sizeof($products); $i<$n; $i++){

$products_string .= (!$once) ? $products[$i] : ',' . $products[$i];

$once = true;

}

}

//copy template only if modified

$template_file = new upload('template');

$template_file->set_destination(DIR_WS_TEMPLATES);

if ($template_file->parse() && $template_file->save()) {

$template = $template_file->filename;

} else {

$template = (isset($HTTP_POST_VARS['previous_template']) ? $HTTP_POST_VARS['previous_template'] : '');

}

 

$sql_data_array = array('title' => $title,

'content' => $content,

'module' => $newsletter_module,

'products' => $products_string,

'template' => $template);

 

if ($action == 'insert') {

$sql_data_array['date_added'] = 'now()';

$sql_data_array['status'] = '0';

$sql_data_array['locked'] = '0';

 

tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array);

$newsletter_id = tep_db_insert_id();

} elseif ($action == 'update') {

tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array, 'update', "newsletters_id = '" . (int)$newsletter_id . "'");

}

 

tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'nID=' . $newsletter_id));

} else {

$action = 'new';

}

break;

case 'deleteconfirm':

$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

tep_db_query("delete from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");

 

tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page']));

break;

case 'delete':

case 'new': if (!isset($HTTP_GET_VARS['nID'])) break;

case 'send':

case 'confirm_send':

$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");

$check = tep_db_fetch_array($check_query);

 

if ($check['locked'] < 1) {

switch ($action) {

case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;

case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;

case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;

case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;

}

 

$messageStack->add_session($error, 'error');

 

tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));

}

break;

}

}

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<div id="spiffycalendar" class="text"></div>

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<?php

f ($action == 'new') {

$form_action = 'insert';

//newsletter products

include(DIR_WS_MODULES . 'newsletters/newsletter_products.php');

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/newsletter_products.php');

$products = new newsletter_products('','', '', '');

 

$parameters = array('title' => '',

'content' => '',

'module' => '',

'products' => '',

'template' => '');

 

$nInfo = new objectInfo($parameters);

 

if (isset($HTTP_GET_VARS['nID'])) {

$form_action = 'update';

 

$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

$newsletter_query = tep_db_query("select title, content, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");

$newsletter = tep_db_fetch_array($newsletter_query);

 

$nInfo->objectInfo($newsletter);

} elseif ($HTTP_POST_VARS) {

$nInfo->objectInfo($HTTP_POST_VARS);

}

 

$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));

$directory_array = array();

if ($dir = dir(DIR_WS_MODULES . 'newsletters/')) {

while ($file = $dir->read()) {

if (!is_dir(DIR_WS_MODULES . 'newsletters/' . $file)) {

if (substr($file, strrpos($file, '.')) == $file_extension) {

$directory_array[] = $file;

}

}

}

sort($directory_array);

$dir->close();

}

 

for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {

$modules_array[] = array('id' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')), 'text' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')));

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr><?php echo tep_draw_form('newsletter', FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'action=' . $form_action, 'post', ' enctype="multipart/form-data" onSubmit="return selectAll(\'newsletter\', \'chosen[]\')"'); if ($form_action == 'update') echo tep_draw_hidden_field('newsletter_id', $nID); ?>

<td><table border="0" cellspacing="0" cellpadding="2">

<tr>

<td class="main"><?php echo TEXT_NEWSLETTER_MODULE; ?></td>

<td class="main"><?php echo tep_draw_pull_down_menu('module', $modules_array, $nInfo->module); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_NEWSLETTER_TITLE; ?></td>

<td class="main"><?php echo tep_draw_input_field('title', $nInfo->title, '', true); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php echo TEXT_NEWSLETTER_CONTENT; ?></td>

<td class="main"><?php echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->content); ?></td>

</tr>

<?php

//newsletter products

?>

<tr>

<td colspan="2"><?php tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>

</tr>

<tr>

<td colspan="2" class="main" align="center"><?php echo TEXT_NEWSLETTER_NOTE; ?></td>

</tr>

<tr>

<td></td>

<td class="main"><?php echo $products->choose_products(); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php echo TEXT_NEWSLETTER_TEMPLATE; ?></td>

<td class="main" valign="top"><?php echo tep_draw_file_field('template') . '<br>' . $nInfo->template . tep_draw_hidden_field('previous_template', $nInfo->template);?></td>

</tr>

<?php

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="main" align="right"><?php echo (($form_action == 'insert') ? tep_image_submit('button_save.gif', IMAGE_SAVE) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). '  <a href="' . tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

</tr>

</table></td>

</form></tr>

<?php

} elseif ($action == 'preview') {

$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

//newsletter products

$newsletter_query = tep_db_query("select title, content, module, products, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");

$newsletter = tep_db_fetch_array($newsletter_query);

$nInfo = new objectInfo($newsletter);

?>

<tr>

<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

</tr>

<?php

if($nInfo->module == 'newsletter_products'){

include(DIR_WS_MODULES . 'newsletters/newsletter_products.php');

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/newsletter_products.php');

$module = new newsletter_products($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template);

?>

<tr>

<td><?php echo $module->html_content(); ?></td>

</tr>

<?php

}else{

?>

<tr>

<td><tt><?php echo nl2br($nInfo->content); ?></tt></td>

</tr>

<?php

}

<tr>

<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

</tr>

<?php

} elseif ($action == 'send') {

$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

$newsletter_query = tep_db_query("select title, content, module, products, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");

//end newsletter products

$newsletter = tep_db_fetch_array($newsletter_query);

 

$nInfo = new objectInfo($newsletter);

 

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

$module_name = $nInfo->module;

//newsletter products

if($nInfo->module == 'newsletter_products'){

$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template);

}else{

$module = new $module_name($nInfo->title, $nInfo->content);

}

?>

<tr>

<td><?php if ($module->show_choose_audience) { echo $module->choose_audience(); } else { echo $module->confirm(); } ?></td>

</tr>

<?php

} elseif ($action == 'confirm') {

$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

$newsletter_query = tep_db_query("select newsletters_id, title, content, module, products, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");

//end newsletter products

$newsletter = tep_db_fetch_array($newsletter_query);

 

$nInfo = new objectInfo($newsletter);

 

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

$module_name = $nInfo->module;

//newsletter products

if($nInfo->module == 'newsletter_products'){

$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template);

}else{

$module = new $module_name($nInfo->title, $nInfo->content);

}

?>

<tr>

<td><?php echo $module->confirm(); ?></td>

</tr>

<?php

} elseif ($action == 'confirm_send') {

$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

 

$newsletter_query = tep_db_query("select newsletters_id, title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");

$newsletter = tep_db_fetch_array($newsletter_query);

 

$nInfo = new objectInfo($newsletter);

 

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));

$module_name = $nInfo->module;

$module = new $module_name($nInfo->title, $nInfo->content);

?>

<tr>

<td><table border="0" cellspacing="0" cellpadding="2">

<tr>

<td class="main" valign="middle"><?php echo tep_image(DIR_WS_IMAGES . 'ani_send_email.gif', IMAGE_ANI_SEND_EMAIL); ?></td>

<td class="main" valign="middle"><b><?php echo TEXT_PLEASE_WAIT; ?></b></td>

</tr>

</table></td>

</tr>

<?php

tep_set_time_limit(0);

flush();

$module->send($nInfo->newsletters_id);

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

</tr>

<?php

} else {

?>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NEWSLETTERS; ?></td>

<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SIZE; ?></td>

<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_MODULE; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_SENT; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>

<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

</tr>

<?php

$newsletters_query_raw = "select newsletters_id, title, length(content) as content_length, module, date_added, date_sent, status, locked from " . TABLE_NEWSLETTERS . " order by date_added desc";

$newsletters_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $newsletters_query_raw, $newsletters_query_numrows);

$newsletters_query = tep_db_query($newsletters_query_raw);

while ($newsletters = tep_db_fetch_array($newsletters_query)) {

if ((!isset($HTTP_GET_VARS['nID']) || (isset($HTTP_GET_VARS['nID']) && ($HTTP_GET_VARS['nID'] == $newsletters['newsletters_id']))) && !isset($nInfo) && (substr($action, 0, 3) != 'new')) {

$nInfo = new objectInfo($newsletters);

}

 

if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) {

echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '\'">' . "\n";

} else {

echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '\'">' . "\n";

}

?>

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id'] . '&action=preview') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $newsletters['title']; ?></td>

<td class="dataTableContent" align="right"><?php echo number_format($newsletters['content_length']) . ' bytes'; ?></td>

<td class="dataTableContent" align="right"><?php echo $newsletters['module']; ?></td>

<td class="dataTableContent" align="center"><?php if ($newsletters['status'] == '1') { echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK); } else { echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS); } ?></td>

<td class="dataTableContent" align="center"><?php if ($newsletters['locked'] > 0) { echo tep_image(DIR_WS_ICONS . 'locked.gif', ICON_LOCKED); } else { echo tep_image(DIR_WS_ICONS . 'unlocked.gif', ICON_UNLOCKED); } ?></td>

<td class="dataTableContent" align="right"><?php if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

</tr>

<?php

}

?>

<tr>

<td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="smallText" valign="top"><?php echo $newsletters_split->display_count($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_NEWSLETTERS); ?></td>

<td class="smallText" align="right"><?php echo $newsletters_split->display_links($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>

</tr>

<tr>

<td align="right" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'action=new') . '">' . tep_image_button('button_new_newsletter.gif', IMAGE_NEW_NEWSLETTER) . '</a>'; ?></td>

</tr>

</table></td>

</tr>

</table></td>

<?php

$heading = array();

$contents = array();

 

switch ($action) {

case 'delete':

$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');

 

$contents = array('form' => tep_draw_form('newsletters', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=deleteconfirm'));

$contents[] = array('text' => TEXT_INFO_DELETE_INTRO);

$contents[] = array('text' => '<br><b>' . $nInfo->title . '</b>');

$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

break;

default:

if (is_object($nInfo)) {

$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');

 

if ($nInfo->locked > 0) {

$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=new') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=unlock') . '">' . tep_image_button('button_unlock.gif', IMAGE_UNLOCK) . '</a>');

} else {

$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=lock') . '">' . tep_image_button('button_lock.gif', IMAGE_LOCK) . '</a>');

}

$contents[] = array('text' => '<br>' . TEXT_NEWSLETTER_DATE_ADDED . ' ' . tep_date_short($nInfo->date_added));

if ($nInfo->status == '1') $contents[] = array('text' => TEXT_NEWSLETTER_DATE_SENT . ' ' . tep_date_short($nInfo->date_sent));

}

break;

}

 

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

echo ' <td width="25%" valign="top">' . "\n";

 

$box = new box;

echo $box->infoBox($heading, $contents);

 

echo ' </td>' . "\n";

}

?>

</tr>

</table></td>

</tr>

<?php

}

?>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Share this post


Link to post
Share on other sites

Wonderful contribution! it is working fine here.

 

It would be nice to have a 'buy' button (as well as a 'wish list' button) added to every product, so that people who read the newsletter, can add products to the cart from within the email itself.

I tried to do this myself, but my knowledge is limited :(

 

Thx

Share this post


Link to post
Share on other sites

What do peoples newsletters look like, i'm not sure if I am doing this right

 

i have inputed all the files etc and generated a html, basic though and all i get is the picture of the product, linked to the site

 

should there be more

 

are there any templates downloadable for this feature

 

Thanks

 

Tarek

RACESPEC

Share this post


Link to post
Share on other sites

This is a great contribution.

 

I have imagemagic1_5 contribution installed. Does anybody know what to change so that my emails use the image magic thumbnails, they look so much better (better rendering).

Share this post


Link to post
Share on other sites

Help with the prices again! I can get the prices to appear but they appear at $0.00!! Can anyone provide me with how their newsletter_products.php looks like (preferrably from someone who altered to it to display special prices as well!) for me to study? :D:D Thx guys.

Share this post


Link to post
Share on other sites

help^^ please?!

 

Help with the prices again! I can get the prices to appear but they appear at $0.00!! Can anyone provide me with how their newsletter_products.php looks like (preferrably from someone who altered to it to display special prices as well!) for me to study?

Edited by jonlai9

Share this post


Link to post
Share on other sites

hi. I want to add the price to the newsletter. Is the following code correct ??

 

 

$images_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and p.products_id in(" . $this->products . ")");

}

while($images = tep_db_fetch_array($images_query)){

if($col > COLS-1){

$html_content .= '</tr><tr><td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '" class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], $images['products_price'],SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>';

$col = 0;

}else{

$html_content .= '<td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '" class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], $images['products_price'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>';

}

$col++;

}

Share this post


Link to post
Share on other sites

Scotty B,

 

I have installed your contribution on a pretty old version of OSC and everything looked good, I had to make a few changes. My version doesn't have admin/includes/filenames.php so I made those changes to application_top.php and I had to add the uploads class since that wasn't there either.

 

I run into trouble when I go to send the email, I get the following error,

Fatal error: Call to undefined function: tep_convert_linefeeds() in /home/majorwoo/public_html/dev/secure/admin/includes/classes/email.php on line 162

The page looks as though it's sending email, but hangs and no email is sent.

 

 

I replaced the existing email.php class with the file in the contrib.

 

Help would be greatly appreciated.

 

Thanks

 

 

Jeremy

Share this post


Link to post
Share on other sites

jonlai9,

 

If your prices are coming out $0.00, then the currencies class is probably working. That means the float price value is empty or not being sent to the $currencies->format() function. The first value sent is the floating price. I would start there.

 

ccng,

 

That code is not correct.

 $html_content .= '<td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '" class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], $images['products_price'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>';

 

You're passing the $images['price'] to the image output function. Try:

 $html_content .= '<td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '" class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a><br>' . $images['products_price']  . '</td>';

 

jbcom,

 

I don't know what version your using, but the error you reported is fatal, meaning that all processes after that error are killed. You need to either get the correct version of the email class or add that function to it.

Edited by scottyb

Share this post


Link to post
Share on other sites
jonlai9,

 

If your prices are coming out $0.00, then the currencies class is probably working. That means the float price value is empty or not being sent to the $currencies->format() function. The first value sent is the floating price. I would start there.

 

Can you show me an example of your code of how it's supposed to be done?

Share this post


Link to post
Share on other sites
Can you show me an example of your code of how it's supposed to be done?

 

Check post #51. I never added the price to the first version of this so that is the best advice I can give you without doing it myself. I think there may be a join missing from the original sql statement to make the specials_price field work.

 

Try this:

"select p.products_id, pd.products_name, p.products_image,

if(s.status, s.specials_new_products_price, NULL) as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on s.products_id = p.products_id where pd.products_id = p.products_id and p.products_id in(" . $this->products . ")"

Share this post


Link to post
Share on other sites

I have got this contribution all working great, but trying to get a nice template to work properly is causing me headaches.

 

I have constructed a template using css to get a nice blue background and round corners

 

this all works great in the preview and when sending, but the actual email received seems to be damaging the css setup at the beginning of the template by adding in <br> where there shouldnt be any

 

i.e. see source code of original css template

 

<html>
<head>
<title>Outdoorbits Newsletter</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body{padding: 20px;background-color: #FFFFFF; font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif}
h1,h2,p{margin: 0 10px}
h1{font-size: 250%;color: #FFFFFF}
h2{font-size: 200%;color: #f0f0f0}
p{padding-bottom:1em}
h2{padding-top: 0.3em}
div#nifty{ margin: 0 10%;background: #9BD1FA}
b.rtop, b.rbottom{display:block;background: #FFFFFF}
b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA}
b.r1{margin: 0 5px}
b.r2{margin: 0 3px}
b.r3{margin: 0 2px}
b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}
</style>
</head>
<body>
<div id="nifty">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
<h1>OutdoorBits.com Newsletter </h1>
<p>As a previous customer of <a href="http://www.outdoorbits.com">http://www.outdoorbits.com</a> you will receive monthly notifications of any new products or special offers we have.<br>
 Below are our new products.  </p>
$html_content

 

 

and here is what newsletter looks like in source of email

 

 

<html><br><head><br><title>Outdoorbits Newsletter</title><br><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><br><style type="text/css"><br>body{padding: 20px;background-color: #FFFFFF; font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif}<br>h1,h2,p{margin: 0 10px}<br>h1{font-size: 250%;color: #FFFFFF}<br>h2{font-size: 200%;color: #f0f0f0}<br>p{padding-bottom:1em}<br>h2{padding-top: 0.3em}<br>div#nifty{ margin: 0 10%;background: #9BD1FA}<br>b.rtop, b.rbottom{display:block;background: #FFFFFF}<br>b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA}<br>b.r1{margin: 0 5px}<br>b.r2{margin: 0 3px}<br>b.r3{margin: 0 2px}<br>b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}<br></style><br></head><br><body><br><div id="nifty"><br><b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b><br><h1>OutdoorBits.com Newsletter </h1><br><p>As a previous customer of <a href="http://www.outdoorbits.com">http://www.outdoorbits.com</a> you will receive monthly notifications of any new products or special offers we have.<br><br>  Below are our new products.  </p>

 

i think its the <br> at end of each style line that is causing issues, any idea what's causing it in the newsletter code ?

Share this post


Link to post
Share on other sites
I have got this contribution all working great, but trying to get a nice template to work properly is causing me headaches.

 

I have constructed a template using css to get a nice blue background and round corners

 

this all works great in the preview and when sending, but the actual email received seems to be damaging the css setup at the beginning of the template by adding in <br> where there shouldnt be any

 

i.e. see source code of original css template

 

<html>
<head>
<title>Outdoorbits Newsletter</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body{padding: 20px;background-color: #FFFFFF; font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif}
h1,h2,p{margin: 0 10px}
h1{font-size: 250%;color: #FFFFFF}
h2{font-size: 200%;color: #f0f0f0}
p{padding-bottom:1em}
h2{padding-top: 0.3em}
div#nifty{ margin: 0 10%;background: #9BD1FA}
b.rtop, b.rbottom{display:block;background: #FFFFFF}
b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA}
b.r1{margin: 0 5px}
b.r2{margin: 0 3px}
b.r3{margin: 0 2px}
b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}
</style>
</head>
<body>
<div id="nifty">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
<h1>OutdoorBits.com Newsletter </h1>
<p>As a previous customer of <a href="http://www.outdoorbits.com">http://www.outdoorbits.com</a> you will receive monthly notifications of any new products or special offers we have.<br>
 Below are our new products.  </p>
$html_content

and here is what newsletter looks like in source of email

<html><br><head><br><title>Outdoorbits Newsletter</title><br><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><br><style type="text/css"><br>body{padding: 20px;background-color: #FFFFFF; font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif}<br>h1,h2,p{margin: 0 10px}<br>h1{font-size: 250%;color: #FFFFFF}<br>h2{font-size: 200%;color: #f0f0f0}<br>p{padding-bottom:1em}<br>h2{padding-top: 0.3em}<br>div#nifty{ margin: 0 10%;background: #9BD1FA}<br>b.rtop, b.rbottom{display:block;background: #FFFFFF}<br>b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA}<br>b.r1{margin: 0 5px}<br>b.r2{margin: 0 3px}<br>b.r3{margin: 0 2px}<br>b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}<br></style><br></head><br><body><br><div id="nifty"><br><b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b><br><h1>OutdoorBits.com Newsletter </h1><br><p>As a previous customer of <a href="http://www.outdoorbits.com">http://www.outdoorbits.com</a> you will receive monthly notifications of any new products or special offers we have.<br><br>  Below are our new products.  </p>

 

i think its the <br> at end of each style line that is causing issues, any idea what's causing it in the newsletter code ?

 

Yup, that's done in the email class and is addressed in v2.

 

find this:

$content = join('', file(DIR_WS_TEMPLATES . $this->template));

 

and add:

$content = str_replace("\n", '', $content);

$content = str_replace("\r", '', $content);

 

after it. That should help. The email class converts linebreaks to <br>'s depending upon your settings.

Share this post


Link to post
Share on other sites

my final stage of enhancement for my store was to add an unsubscribe link at the bottom to an unsub file

 

i tried changing the send function in /admin/includes/modules/newsletters/newsletter_products.php as follows

 

	function send($newsletter_id) {
  $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  while ($mail = tep_db_fetch_array($mail_query)) {
		  $mailout = $mail['customers_email_address'];
		  echo "<font face=Arial>Sent mail to $mailout<br>";
		  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
		  $mimemessage->add_html($this->html_content() . "\n\n<FONT size=-2>" . TEXT_NEWSLETTER_OPTOUT . "\nUnsubscribe\n" . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_NEWS_OPTOUT . "?email=" . $result['customers_email_address'] . '">'  . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_NEWS_OPTOUT . "?email=" . $result['customers_email_address'] . '</a>' . "</FONT>\n\n");
		  $mimemessage->build_message();			  
		$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
  }
  $newsletter_id = tep_db_prepare_input($newsletter_id);
  tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
 }

 

but this is giving me an error as follows:-

 

Fatal error: Cannot redeclare class currencies in /home/fbadmin/public_html/admin/includes/classes/currencies.php on line 16

 

when i try to send the newsletter.

 

I think its due to the mimemessage being built within the while loop, but can't see a way around this and still be pulling the relevant email address from database to populate my unsubscribe link

 

anyone got a way around this please :)

Share this post


Link to post
Share on other sites

fuzioneer,

 

You've got an extra $currencies = new currencies() somewhere. The best (osCommerce) way is to put it once in the top of admin/newsletters.php.

 

qwick,

 

I haven't used the image magic contribution, but if it's anything like the "on the fly" thumbnailer, I wouldn't try to use it. The on the fly, produces images on an on call basis, which won't be supported by email programs. Of course I haven't tried it, but mail programs are finicky reading html. Through my own bungling/research, I've found that the best solution for html newsletters is to keep it as trim as possible. Use only what works across the majority of programs.

Share this post


Link to post
Share on other sites

thx for the tip Scott

I tried adding the following to admin/newsletters.php

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

and i now get the error

 

Fatal error: Cannot redeclare class currencies in /home/fbadmin/public_html/admin/includes/classes/currencies.php on line 16 ??

Edited by fuzioneer

Share this post


Link to post
Share on other sites
Check post #51. I never added the price to the first version of this so that is the best advice I can give you without doing it myself. I think there may be a join missing from the original sql statement to make the specials_price field work.

 

Try this:

"select p.products_id, pd.products_name, p.products_image,

if(s.status, s.specials_new_products_price, NULL) as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on s.products_id = p.products_id where pd.products_id = p.products_id and p.products_id in(" . $this->products . ")"

 

Can you tell me exactly where to put that? And is that the only line I need to alter? I tried changing $products_query with that line and it doesn't work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×