Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Mailist and SPPC


monikart

Recommended Posts

I have SPPC installed running good. I recently installed Newsletter/Mailist 4.0 and it also functions OK on the front end. Reports fine in admin too but the newsletter does not get sent to those who signed up via the mailist form on the site. Only to the registered account holders. here is my admin/includes/modules/newsletter.php:

<?php
/*
 $Id: newsletter.php 1739 2007-12-20 00:52:16Z hpdl $
adapted for Separate Pricing Per Customer v4.2 2007/02/10

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 class newsletter {
var $show_choose_audience, $title, $content;

function newsletter($title, $content, $send_to_customer_groups) {
  $this->show_choose_audience = false;
  $this->title = $title;
  $this->content = $content;
// BOF Separate Pricing Per Customer
  $this->send_to_customer_groups = $send_to_customer_groups;
// EOF Separate Pricing Per Customer
}

function choose_audience() {
  return false;
}

function confirm() {
  global $HTTP_GET_VARS;

// BOF Separate Pricing Per Customer
  if (tep_not_null($this->send_to_customer_groups)) {
  $mail_query1 = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1' and customers_group_id in (" . $this->send_to_customer_groups . ")");
  $mail_query2 = tep_db_query("select count(*) as count from " . TABLE_NEWSLETTER . " where customers_newsletter 	= '1'");
  } else {
  $mail_query1 = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  $mail_query2 = tep_db_query("select count(*) as count from " . TABLE_NEWSLETTER . " where customers_newsletter 	= '1'");
  }
// EOF Separate Pricing Per Customer
$mail1 = tep_db_fetch_array($mail_query1);
$mail2 = tep_db_fetch_array($mail_query2);

$mail['count'] = ($mail1['count'] + $mail2['count'] );

  $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</b></font></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><b>' . $this->title . '</b></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td align="right"><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <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></td>' . "\n" .
					'  </tr>' . "\n" .
					'</table>';

  return $confirm_string;
}

// BOF Separate Pricing Per Customer
function send($newsletter_id, $send_to_customer_groups) {
	if (tep_not_null($send_to_customer_groups)) {
  $mail_query1 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1' and customers_group_id in (" . $send_to_customer_groups . ")");
  $mail_query2 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . 		TABLE_NEWSLETTER . " where customers_newsletter = '1'");
	} else {
  $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
	}
// EOF Separate Pricing Per Customer

	  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
	  $mimemessage->add_text($this->content);
	  $mimemessage->build_message();
	  while ($mail = tep_db_fetch_array($mail_query1)) {
	$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 	$mail['customers_email_address'], '', EMAIL_FROM, $this->title);
	  }
  while ($mail = tep_db_fetch_array($mail_query2)) {
	$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) . "'");
	}
 }
?>

 

Any help would be appreciated.

What would you do if you knew you could not fail?

Link to comment
Share on other sites

Ok, well it seems to be sending it but it is not giving me a count at the top of the page of those Mailist sign ups. there is some finessing it. The code above is my attempt at installing the code in an already edited newsletter.php. Post if you experience this issue and lets see how we could improve it to work well with sppc

 

I have SPPC installed running good. I recently installed Newsletter/Mailist 4.0 and it also functions OK on the front end. Reports fine in admin too but the newsletter does not get sent to those who signed up via the mailist form on the site. Only to the registered account holders. here is my admin/includes/modules/newsletter.php:

<?php
/*
 $Id: newsletter.php 1739 2007-12-20 00:52:16Z hpdl $
adapted for Separate Pricing Per Customer v4.2 2007/02/10

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 class newsletter {
var $show_choose_audience, $title, $content;

function newsletter($title, $content, $send_to_customer_groups) {
  $this->show_choose_audience = false;
  $this->title = $title;
  $this->content = $content;
// BOF Separate Pricing Per Customer
  $this->send_to_customer_groups = $send_to_customer_groups;
// EOF Separate Pricing Per Customer
}

function choose_audience() {
  return false;
}

function confirm() {
  global $HTTP_GET_VARS;

// BOF Separate Pricing Per Customer
  if (tep_not_null($this->send_to_customer_groups)) {
  $mail_query1 = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1' and customers_group_id in (" . $this->send_to_customer_groups . ")");
  $mail_query2 = tep_db_query("select count(*) as count from " . TABLE_NEWSLETTER . " where customers_newsletter 	= '1'");
  } else {
  $mail_query1 = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  $mail_query2 = tep_db_query("select count(*) as count from " . TABLE_NEWSLETTER . " where customers_newsletter 	= '1'");
  }
// EOF Separate Pricing Per Customer
$mail1 = tep_db_fetch_array($mail_query1);
$mail2 = tep_db_fetch_array($mail_query2);

$mail['count'] = ($mail1['count'] + $mail2['count'] );

  $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</b></font></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><b>' . $this->title . '</b></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
					'  </tr>' . "\n" .
					'  <tr>' . "\n" .
					'	<td align="right"><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <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></td>' . "\n" .
					'  </tr>' . "\n" .
					'</table>';

  return $confirm_string;
}

// BOF Separate Pricing Per Customer
function send($newsletter_id, $send_to_customer_groups) {
	if (tep_not_null($send_to_customer_groups)) {
  $mail_query1 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1' and customers_group_id in (" . $send_to_customer_groups . ")");
  $mail_query2 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . 		TABLE_NEWSLETTER . " where customers_newsletter = '1'");
	} else {
  $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
	}
// EOF Separate Pricing Per Customer

	  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
	  $mimemessage->add_text($this->content);
	  $mimemessage->build_message();
	  while ($mail = tep_db_fetch_array($mail_query1)) {
	$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 	$mail['customers_email_address'], '', EMAIL_FROM, $this->title);
	  }
  while ($mail = tep_db_fetch_array($mail_query2)) {
	$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) . "'");
	}
 }
?>

 

Any help would be appreciated.

What would you do if you knew you could not fail?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...