Admin Tip: Send Email to Customers who havent purchased yet

ldavies83 <[email protected]>
Newsgroups gmane.comp.web.oscommerce.tips
Message-ID <f2ec8b1d99f26680a7c55fa2e3290c0a@osCommerce-Forums>
This message was sent from: Tips and Tricks
http://forums.oscommerce.com/viewtopic.php?p=196606#196606
----------------------------------------------------------------

I have quite a new site ([url]www.starchsupplies.co.uk[/url]) and as usual I had a couple of teething problems with the ordering system. Now I had customers details, but no orders. I wanted to send all customers who hadnt ordered yet a 10% off discount voucher via the Admin > Send Email page, but not the ones who have ordered. Solution? Remarkably easy actually, first open your [b]admin/mail.php[/b] and just after:
[code]
      case '**D':
        $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
        $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
        break;
[/code]
 insert the following lines:
[code]
// NEW EMAIL OPTION - START
	case '**F':
	  $mail_query = tep_db_query("SELECT " . TABLE_CUSTOMERS . ".customers_firstname, " . TABLE_CUSTOMERS . ".customers_lastname, " . TABLE_CUSTOMERS . ".customers_email_address FROM " . TABLE_CUSTOMERS . " LEFT JOIN " . TABLE_ORDERS . " ON " . TABLE_CUSTOMERS . ".customers_id = " . TABLE_ORDERS . ".customers_id WHERE " . TABLE_ORDERS . ".customers_id Is Null");
	  $mail_sent_to = TEXT_CUSTOMERSNOTORDEREDYET;
	  break;
// NEW EMAIL OPTION - FINISH
[/code]

Next, further down the file look for:

[code]  
if ( ($HTTP_GET_VARS['action'] == 'preview') && ($HTTP_POST_VARS['customers_email_address']) ) {
    switch ($HTTP_POST_VARS['customers_email_address']) {
      case '***':
        $mail_sent_to = TEXT_ALL_CUSTOMERS;
        break;
      case '**D':
        $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
        break;
[/code]

Insert the following:

[code]
// NEW EMAIL OPTION - START
	case '**F':
	  $mail_sent_to = TEXT_CUSTOMERSNOTORDEREDYET;
	  break;
// NEW EMAIL OPTION - FINISH
[/code]

Lastly in this file, find:

[code]
    $customers = array();
    $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
    $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
    $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
[/code]

and insert after that:

[code]
// NEW EMAIL OPTION - START
    $customers[] = array('id' => '**F', 'text' => TEXT_CUSTOMERSNOTORDEREDYET);
// NEW EMAIL OPTION - FINISH
[/code]

Right, Next file! goto [b]admin/includes/languages/english/mail.php[/b] and add:
[code]
// NEW EMAIL OPTION - START
define('TEXT_CUSTOMERSNOTORDEREDYET','To Customers who have not placed an order');
// NEW EMAIL OPTION - FINISH[/code]

in the text definitions. 

After you've made these changes, you will have another dropdown menu choice on the Admin > Tools > Send Email page in "Customer" combo

This is my first tip contributed, so I would apreciate any pointers on making things easier to read. Grammer was never my forte! :oops:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.