I think I've fixed the duplicate email address/duplicate email send bug.
Zen Cart doesn't usually allow more than one account to have the same email address so I needed to limit the number of emails sent to 1 if a specific email address was selected.
The duplicate emails can get costly when sending Gift Certificates from Admin
In file includes/functions/audience.php, I have changed function get_audience_sql_query to:
Code:
function get_audience_sql_query($selected_entry, $query_category='email') {
// This is used to take the query_name selected in the drop-down menu or singular customer email address and
// generate the SQL Select query to be used to build the list of email addresses to be sent to
// it only returns a query name and query string (SQL SELECT statement)
// the query string is then used in a $db->Execute() command for later parsing and emailing.
global $db;
$query_name='';
$queries_list = $db->Execute("select query_name, query_string from " . TABLE_QUERY_BUILDER . " " .
"where query_category like '%" . $query_category . "%'");
// "where query_category = '" . $query_category . "'");
while (!$queries_list->EOF) {
if ($selected_entry == $queries_list->fields['query_name']) {
$query_name = $queries_list->fields['query_name'];
$query_string = parsed_query_string($queries_list->fields['query_string']);
//echo 'GET_AUD_EM_ADDR_QRY:<br />query_name='.$query_name.'<br />query_string='.$query_string;
}
$queries_list->MoveNext();
}
//if no match found against queries listed in database, then $selected_entry must be an email address
if ($query_name=='' && $query_category=='email') {
$cust_email_address = zen_db_prepare_input($selected_entry);
$query_name = $cust_email_address;
$query_string = "select customers_firstname, customers_lastname, customers_email_address
from " . TABLE_CUSTOMERS . "
where customers_email_address = '" . zen_db_input($cust_email_address) . "' limit 1";
}
//send back a 1-row array containing the query_name and the SQL query_string
return array('query_name'=>$query_name, 'query_string'=>$query_string);
}
Bookmarks